Skip to content

Instantly share code, notes, and snippets.

@iuliaL
Created September 20, 2016 15:22
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 iuliaL/037bd14fdd686ed85a143f79d2adb551 to your computer and use it in GitHub Desktop.
Save iuliaL/037bd14fdd686ed85a143f79d2adb551 to your computer and use it in GitHub Desktop.
...
function validateEmail(email) {
return /.+@.+/.test(email);
}
$("form").on("submit", function(event){
var inputArray = $(this).find("input");
var valid = true;
inputArray.each(function(index,input){
if(input.attr("required") !== undefined && !input.val()){
return valid = false;
}
if (input.attr("type") == "email" && !validateEmail(input.val())) {
return valid = false;
}
});
return valid
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment