Enable Disable Submit Button If One Checkbox is Checked

This is very simple tutorial which enable submit button if at least one checkbox is checked otherwise disable submit button.

Enable Disable Submit Button

Note: Don’t forget to include the jQuery library in the header or footer.

Demo: https://jsfiddle.net/javedfiddle/fj8r9w9v/

HTML:

<form method="post" action="">
<input class="chk" type="checkbox" name="html" value="html" />HTML<br/>
<input class="chk" type="checkbox" name="javascript" value="javascript" />JavaScript<br/>
<input class="chk" type="checkbox" name="jquery" value="jquery" />JQuery<br/><br/>
<input type="submit" name="submit" id="submit" value="Submit" />
</form>

JavaScript:

$('#submit').prop("disabled", true);
$('input:checkbox').click(function() {
 if ($(this).is(':checked')) {
 $('#submit').prop("disabled", false);
 } else {
 if ($('.chk').filter(':checked').length < 1){
 $('#submit').attr('disabled',true);}
 }
});

Demo: https://jsfiddle.net/javedfiddle/fj8r9w9v/

Leave your comments if you find this tutorial helpful.

Advertisements

One thought on “Enable Disable Submit Button If One Checkbox is Checked

  1. Pingback: Enable Disable Submit Button If One Checkbox is Checked | Dinesh Ram Kali.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s