Why isn't email validation checking for space?

  • Profile Image
    BPTGuy
    Asked on March 14, 2013 at 01:05 AM

    Email field with validation turned on is correctly identifying the following as invalid:

     

    test@@email.com

    testatemail.com

    test%email.com

     

    However, when I type in an email address with a space in it, the validation didn't catch it and allowed it to be submitted.  For example, "test email@mail.com" is accepted.

     

    Thank you.

  • Profile Image
    EltonCris
    Answered on March 14, 2013 at 04:07 AM

    Hi BPTGuy,

    Well since we knew that emails can't contain any spaces, you can always remove it manually. Or if that's important to you, you can always download your form source code and modify email regex under jotform.js.

    Find this on jotform.js file:

    var reg = {

    and replace the email regex below it to this:

    email: /^\S[a-z0-9!#$%&'*+\/=?\^_`{|}~\-]+(?:\.[a-z0-9!#$%&'*+\/=?\^_`{|}~\-]^\S+)*@(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\-]*[a-z0-9])/i,

    Example: https://shots.jotform.com/elton/email_nospace/

    Hope this still helps. Thanks!

  • Profile Image
    BPTGuy
    Answered on March 15, 2013 at 12:51 AM

    Hi EltonCris,

    Thank you very much for your reply.  I certainly know that email addresses cannot contain any spaces, but that's not the point.  The idea of having email address valiation is to prevent people from entering invalid email address.  If the validation can catch the mistake of having double @@ or no @, why can't it also catch the space in the bad email address?

    Thank you for the workaround you provided.

  • Profile Image
    EltonCris
    Answered on March 15, 2013 at 02:52 AM

    Your welcome!

    Thanks for using JotForm!