thready
asked on
javascript email validation function with regex
Hi Experts,
There are a zillion regex email validation functions that exist for javascript. Unfortunately, none of them that I've seen are truly professional - and don't validate according to the RFC.
Can someone point me to one that truly works? I won't tell you what my test is just yet, but it may make for an interesting discussion.. :-)
Thank you,
Mike
There are a zillion regex email validation functions that exist for javascript. Unfortunately, none of them that I've seen are truly professional - and don't validate according to the RFC.
Can someone point me to one that truly works? I won't tell you what my test is just yet, but it may make for an interesting discussion.. :-)
Thank you,
Mike
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The double backslashes allow for the possibility that one may actually choose to have an @ sign in the local portion of his email. According to RFC you can have a legitimate email address as follows:
"Abc\@def"@example.com
Crazy yes, and most mainstream domains (gmail, yahoo, etc) restrict that, but nonetheless, it is possible.
ASKER
Thank you very much for the extra great help!!
Cheers, and have a nice weekend! :-)
Cheers, and have a nice weekend! :-)
ASKER
var EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A
+ "[A-Za-z0-9-]+(\\.[A-Za-z0
which does appear less accurate than yours. But we need apostrophes to be allowed. And I'm thinking I can just add them like this:
var EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A
+ "[A-Za-z0-9-]+(\\.[A-Za-z0
However, I'm just trying to understand the expression we had. Could you tell me why we have the double backslashes before the @ sign? If you could just explain the ones coming before the '.' that occurs before the @ in the email, I'd really appreciate it!