Last active
March 12, 2021 06:27
Star
You must be signed in to star a gist
javascript: strict e-mail address verification
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
/** | |
* Provides strict e-mail address verification | |
* Includes support for unicode | |
* | |
* @param string e-mail address to verify | |
* @return boolean true if e-mail address is valid, false otherwise | |
*/ | |
function validEmail (email) { | |
'use strict' | |
return typeof email === 'string' && | |
email && | |
email.length < 256 && | |
/^(?:[0-z!#$%&'*+/=?^_`{|}.~-]|[^\u0000-\u007F]){1,64}@(?:(?:[0-z-]|[^\u0000-\u007F]){1,62}\.)+(?:[0-z]|[^\u0000-\u007F]){2,63}$/i.test(email) && | |
email.indexOf('..') === -1 && | |
email.indexOf('.') !== 0 && | |
email.indexOf('.@') === -1 && | |
email.indexOf('-.') === -1 && | |
email.indexOf('.-') === -1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment