Last active
September 14, 2016 03:09
-
-
Save jeffreysbrother/181485aefec0baf38b52d982e00d6628 to your computer and use it in GitHub Desktop.
Add jQuery form validation where HTML5 validation is not supported (Safari)
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
$("form").submit(function(e) { | |
var ref = $(this).find("[required]"); | |
$(ref).each(function() { | |
if ( $(this).val() == '' ) { | |
alert("Required field should not be blank."); | |
$(this).focus(); | |
e.preventDefault(); | |
return false; | |
} | |
}); return true; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment