Created
March 10, 2013 14:35
-
-
Save phlco/5128799 to your computer and use it in GitHub Desktop.
email validator
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
function validateEmail(){ | |
//testing regular expression | |
var a = $("#email").val(); | |
// explination of symbols at: http://www.zparacha.com/validate-email-address-using-javascript-regular-expression/ | |
var filter = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/; | |
//if it's valid email | |
if(filter.test(a)){ //The test() method tests for a match in a string. | |
return true; | |
} | |
//if it's NOT valid | |
else{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment