Disable Submit button until Checkbox is checked

In this tutorial, I'll show you how to Disable Submit button until Checkbox is checked using Jquery.

Click Here for DEMO

First thing, we need HTML to create the form with checkbox and submit button. Here is the code:

<h2>Disable Submit button until Checkbox is checked</h2>
<form action="#" class="form">
      <div class="row">
         <input type="checkbox" id="accept"><label for="accept">I accept the terms and conditions.</label>
      <input type="submit" value="Send" id="send" disabled="disabled">

Then, we need CSS to style up the things. Here I use SCSS so I'll share you SCSS code.
      margin: 0 0 15px;

      margin: 0 5px 0 0;

   input[type=submit] {
      background: $light-blue;
      color: $white;
      padding: 7px 15px;
      border: 0;

         opacity: 0.6;

            background: $light-blue;

         background: darken($light-blue, 15%);

Finally, we need Jquery Code to disable submit button until checkbox is checked. So, here's the Jquery below.
  if($('#send').is(':disabled')) {
  } else {
   $('#send').attr('disabled', 'disabled');

I hope this is working well. If you have any thought or any new sharing, feel free to comment below.


Share this

Related Posts