Skip to content

Instantly share code, notes, and snippets.

@ckschmieder
Created May 6, 2017 20:22
Show Gist options
  • Save ckschmieder/b9cd22e2b6e9dae759afbae85e228b28 to your computer and use it in GitHub Desktop.
Save ckschmieder/b9cd22e2b6e9dae759afbae85e228b28 to your computer and use it in GitHub Desktop.
Trying to prevent submission of the form if the checkbox isn't checked. The alert is working properly but the form still submits after dismissing the alert.
$(function(){
$('#NationalPhotoMonth_submitButton').click(function(e) {
e.preventDefault();
if(!$('#NationalPhotoMonth_Field_48').is(':checked')){
alert('You must agree to the term and conditions.');
return false;
}
if($('#NationalPhotoMonth_Field_48').is(':checked')){
return true;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment