What is the best way to validate an email address

  • mzangari
    Asked on September 30, 2016 at 4:27 PM

    I am looking to validate an email address before form submission. At the top of the form, I have an email field which has some conditional logic applied to ensure that the email address does not contain certain text (eg, email address cannot contain "gmail.com"). I have added the Email Validator widget before the submit button, but there is really nothing that would prevent the user from entering an accepted email address at the top of the form and using an "@gmail.com" email address to validate their email address.

    Is there a way to either have the email form perfrom a validation, or perhaps hard code the Email Validator input field with whatever value was entered into the email form at the top of the page?

    I'm also open to any other suggestions that you may have. I'm ultimately looking for a way to prevent a user from submitting a form if the email address is on our "do not allow" list.

     

    Thanks!

  • Kevin Support Team Lead
    Replied on September 30, 2016 at 8:53 PM

    The widget you're using will validate if the email exists only, it will no verify the domain where the email belongs. 

    What I would suggest you is to use conditions, you may evaluate if the email address contains either "gmail" or "gmail.com" in it and then alert the user about it. 

    I have set up this in a sample form, this is the condition that I've used: 

    What is the best way to validate an email address Image 1 Screenshot 20

    This way you can show a text message indicating that the domain is not allowed, here is also a guide about show or hide fields based on other field's input: How-to-Show-or-Hide-Fields-Base-on-User-s-Answer

    Here is also the link to my form, to test it, please enter a Gmail address and you will get the message: https://form.jotform.com/62737697316973 

    Hope this helps. 

  • mzangari
    Replied on September 30, 2016 at 9:32 PM

    thanks for the reply.  Sorry for the confusion, I'm actually looking to understand how I can validate an email address, rather than how I can use the conditions blacklist email addresses. 

     

    1.  In my form, i have the following email Field in place:

    2.  I have conditions similar to this in place:

     

     

     

    3.  I then have the "Email Validator" Widget in place before the Submit button.

     

     

    What I am trying to do is allow the form to be submitted:

    IF

    the email address entered in #1 does not meet the conditions in #2

    AND

    the email used in the email Validator (#3) does not meet the same conditions in #2. 

    Hopefully that makes sense. 

    If there is a way to auto populate #3 with the email address entered in #1, that might be the easiest way to accomplish what I'm looking to do. 

    thanks again for your reply!

  • Ashwin JotForm Support
    Replied on October 1, 2016 at 10:57 AM

    Hello mzangari,

    If I understand your question correctly, you want the #1 email address which was input by user to be populated automatically in #2 & #3 as well. Is that correct?

    Yes it is possible to achieve your requirement by taking advantage of "Update / Calculate field Conditions" feature. You may like to take a look at the following guide which should help you:  https://www.jotform.com/help/286-How-to-Pass-Field-Value-to-Another-Field 

    Do get back to us if you would like us to implement this in your form and we will do the needful. 

    Thank you!

  • mzangari
    Replied on October 1, 2016 at 1:57 PM

    Hello, thanks again for the reply.  This sounds like it would get me to 90% of what I am trying to achieve.  I tried to implement what you suggested, but i have not been successful in getting it to update the fields based on the conditions.  Here is the condition I have created:

     

    What is the best way to validate an email address Image 1 Screenshot 30

    When I populate {E-mail}, it is not updating  the"Email Validator" Widget with {E-mail}.  Should this work?

     

    Here is an example of the Email Validator Widget, when viewed through Preview, after having entered an email address for {E-mail}.  Notice that it does not have the value from {E-mail}:

    What is the best way to validate an email address Image 2 Screenshot 41

  • Kevin Support Team Lead
    Replied on October 1, 2016 at 8:50 PM

    Yes, I have checked the conditions you are trying to set up and seems like there is no way to set a value to the E-Mail Validator widget using conditions, I have also tried with the Form Calculation widget in order to find if the value in the E-Mail Validator widget can be taken and this is not possible either.

    This seems to be due to how the widget works, please do note that widgets are added to the form in a different way compared to Basic and Quick Fields, so far there is not much the we can do in order to pre-populate the data in this widget nor take its value to be handled by other functions or widgets. 

    If you still require to use the validator widget  I would suggest you to state this in the form, so your users will know they need to use the same email in all the fields.