Created
November 8, 2013 08:42
-
-
Save caingougou/7368130 to your computer and use it in GitHub Desktop.
email validation
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
isEmail: function(email) { | |
var splitted = email.match("^(.+)@(.+)$"); | |
if (splitted == null) return false; | |
if (splitted[1] != null) | |
{ | |
var regexp_user = /^\"?[\w-_\.]*\"?$/; | |
if (splitted[1].match(regexp_user) == null) return false; | |
} | |
if (splitted[2] != null) | |
{ | |
var regexp_domain = /^[\w-\.]*\.[A-Za-z]{2,4}$/; | |
if (splitted[2].match(regexp_domain) == null) | |
{ | |
var regexp_ip = /^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/; | |
if (splitted[2].match(regexp_ip) == null) return false; | |
} // if | |
return true; | |
} | |
return false; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment