jQuery Cochez si CheckBox n'est pas coché
if (!$("#checkboxID").is(":checked")) {
// do something if the checkbox is NOT checked
}
C0W
if (!$("#checkboxID").is(":checked")) {
// do something if the checkbox is NOT checked
}
<form id="form1" action="/controller/action" method="post">
<input type="checkbox" name="box1" class="cBox" />
<input type="checkbox" name="box2" class="cBox" />
<input type="checkbox" name="box3" class="cBox" />
<input type="submit" value="Submit" />
</form>
<script>
$('#form1').submit(function() {
if ($('input:checkbox', this).length == $('input:checked', this).length ) {
// everything's fine...
} else {
alert('Please tick all checkboxes!');
return false;
}
});
</script>
$('#checkAll').click(function () {
$('input:checkbox').prop('checked', this.checked);
});