CRM Webform Email Validation

CRM Webform Email Validation

Hello!
I've been trying to use CRM Webforms to collect data about future leads on a landing page. However, I have stumbled upon a very big problem. The form does not actually validate that the e-mail that was filled in has a valid structure. I checked out the code for embedding the form into another website and found a possible typo in the validateEmail function and will post my solution here (though I'd rather it be fixed so I can embed the form into a Zoho Sites website without tinkering with the website's css directly) .

This is the function that the embed code generates in order to validate the structure of the email field (it only appears if there is an email field in your form):
  1. function validateEmail()
        {
            var emailFld = document.querySelectorAll('[ftype=email]'); //potential problem here, since ftype is not an html attribute existing in the email field element
            var i;
            for (i = 0; i < emailFld.length; i++)
            {
                var emailVal = emailFld[i].value;
                if((emailVal.replace(/^\s+|\s+$/g, '')).length!=0 )
                {
                    var atpos=emailVal.indexOf('@');
                    var dotpos=emailVal.lastIndexOf('.');
                    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailVal.length)
                    {
                        alert('Please enter a valid email address. ');
                        emailFld[i].focus();
                        return false;
                    }
                }
            }
            return true;
        }
My own solution was replacing the selector for the email field
by replacing [ftype="email"] with [name="email"].

I'd like to know if there is a way for the CRM Webform to validate email structure when it is embedded directly in Zoho Sites from the Forms section when you add elements.

Thank you for your attention!

    Access your files securely from anywhere









                          Zoho Developer Community




                                                • Desk Community Learning Series


                                                • Digest


                                                • Functions


                                                • Meetups


                                                • Kbase


                                                • Resources


                                                • Glossary


                                                • Desk Marketplace


                                                • MVP Corner


                                                • Word of the Day


                                                • Ask the Experts





                                                          Manage your brands on social media



                                                                Zoho TeamInbox Resources



                                                                    Zoho CRM Plus Resources

                                                                      Zoho Books Resources


                                                                        Zoho Subscriptions Resources

                                                                          Zoho Projects Resources


                                                                            Zoho Sprints Resources


                                                                              Qntrl Resources


                                                                                Zoho Creator Resources



                                                                                    Zoho CRM Resources

                                                                                    • CRM Community Learning Series

                                                                                      CRM Community Learning Series


                                                                                    • Kaizen

                                                                                      Kaizen

                                                                                    • Functions

                                                                                      Functions

                                                                                    • Meetups

                                                                                      Meetups

                                                                                    • Kbase

                                                                                      Kbase

                                                                                    • Resources

                                                                                      Resources

                                                                                    • Digest

                                                                                      Digest

                                                                                    • CRM Marketplace

                                                                                      CRM Marketplace

                                                                                    • MVP Corner

                                                                                      MVP Corner







                                                                                        Design. Discuss. Deliver.

                                                                                        Create visually engaging stories with Zoho Show.

                                                                                        Get Started Now


                                                                                          Zoho Show Resources

                                                                                            Zoho Writer

                                                                                            Get Started. Write Away!

                                                                                            Writer is a powerful online word processor, designed for collaborative work.

                                                                                              Zoho CRM コンテンツ






                                                                                                Nederlandse Hulpbronnen


                                                                                                    ご検討中の方