Skip to content

Instantly share code, notes, and snippets.

@jawinn
Last active December 21, 2015 03:19
Show Gist options
  • Save jawinn/6241779 to your computer and use it in GitHub Desktop.
Save jawinn/6241779 to your computer and use it in GitHub Desktop.
jQuery - Required checkbox to submit form (simple w/ alert)
// checkbox must be checked to submit form
$('#contact-submit').click(function(e) {
var checked = $('#contact-side :checkbox:checked').length;
if (checked == 0) {
alert('Before this form can be sent, you must agree to the disclaimer.');
e.preventDefault();
} else {
$('#contact-side form').submit();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment