Skip to content

Instantly share code, notes, and snippets.

@phlco
Created March 10, 2013 14:35
Show Gist options
  • Save phlco/5128799 to your computer and use it in GitHub Desktop.
Save phlco/5128799 to your computer and use it in GitHub Desktop.
email validator
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