Skip to content

Instantly share code, notes, and snippets.

@jeffreysbrother
Last active September 14, 2016 03: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 jeffreysbrother/181485aefec0baf38b52d982e00d6628 to your computer and use it in GitHub Desktop.
Save jeffreysbrother/181485aefec0baf38b52d982e00d6628 to your computer and use it in GitHub Desktop.
Add jQuery form validation where HTML5 validation is not supported (Safari)
$("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