Created
November 29, 2010 10:32
-
-
Save badsyntax/719800 to your computer and use it in GitHub Desktop.
rfc822 email validation in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See http://rosskendall.com/blog/web/javascript-function-to-check-an-email-address-conforms-to-rfc822 | |
function isEmail(email){ | |
return /^([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x5b([^\x0d\x5b-\x5d\x80-\xff]|\x5c[\x00-\x7f])*\x5d))*$/.test( email ); | |
} |
abc@def -said it's a valid email?
@kapitannwel have the same issue with hgdyugf@yahoo (
Any ideas on how to solve it?)
According to wikipedia, this email should be a valid email.
Dörte@Sörensen.example.com
But the
ö
appears to make this regex test fail.Thoughts?
Is this a valid email, but just not valid under RFC 822?
This one matched your example email: https://github.com/jackfoxy/FsRegEx/blob/master/tests/Email.Tests/Ultimate.fs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
According to wikipedia, this email should be a valid email.
Dörte@Sörensen.example.com
But the
ö
appears to make this regex test fail.Thoughts?
Is this a valid email, but just not valid under RFC 822?