Skip to content

Instantly share code, notes, and snippets.

@akmur
Last active December 11, 2015 10:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akmur/4585189 to your computer and use it in GitHub Desktop.
Save akmur/4585189 to your computer and use it in GitHub Desktop.
Simple email validation
$('input#submit').click(function(){
var email = $('input#email').val();
var flag = true;
$('input.req').each(function(){
// if the input.req is empty...
if ($(this).val() == "") {
$(this).nextAll('span:first').fadeIn();
flag = false;
} else {
// if the input#email field has no @ sign...
if(email.indexOf('@') == -1) {
$('form span').fadeIn();
flag = false;
}
}
});
return flag;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment