I want that when one or all the checkbox are checked, submit button is not disabled. But if the checkboxes are not checked, then the submit is disabled.
I wrote this code :
$('input[type="submit"]').prop('disabled', true).addClass('disabled');
$('input[type="checkbox"]').click(function(){
if (this.checked) {
$('input[type="submit"]').prop('disabled', false).removeClass('disabled');
} else {
$('input[type="submit"]').prop('disabled', true).addClass('disabled');
}
});
.disabled {
background-color: #ececec !important;
border: none;
}
input[type="submit"] {
background-color: green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="checkbox">
<input type="checkbox">
<input type="checkbox">
<input type="submit" value="Send">
It's almost working but when I uncheck one checkbox, the submit button is already disabled but my others checkboxes are still checked.
Thanks for your help