Created
September 20, 2016 15:22
-
-
Save iuliaL/037bd14fdd686ed85a143f79d2adb551 to your computer and use it in GitHub Desktop.
...
This file contains hidden or 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(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