3

I have this:

<fieldset id="booom">
<label><INPUT TYPE="checkbox" NAME="a" VALUE="a">something></label>
<label><INPUT TYPE="checkbox" NAME="b" VALUE="b">something></label>
<label><INPUT TYPE="checkbox" NAME="c" VALUE="c">something></label>
</fieldset>

<input type="button" id="answer" value="submit">

How can I check with jQuery if all checkboxes from fieldset 'booom' are unchecked on submit?

So:

if (all checkboxes from parent 'booom' are unchecked) {
alert("something")
}

I found many posts about this but none with an actual simple working sample with a button and an alert box :)

Thanks!

user1525612
  • 1,864
  • 1
  • 21
  • 33

1 Answers1

6

You can use the :checked modifier in a selector.

if ($("#boom :checkbox:checked").length == 0) {
    alert("You have to check at least one box");
}
Barmar
  • 741,623
  • 53
  • 500
  • 612