bba bba - 6 months ago 33
Javascript Question

jQuery see if any or no checkboxes are selected

I know how to see if an individual checkbox is selected or not.

But Im having trouble with the following - given a form id I need to see if any of the checkboxes are selected (i.e 1 or more), and I need to see if none are selected. Basically I need two separate functions that answer these two questions. Help would be appreciated. Thanks!

Actually, I would just need a function to tell me if none are selected. Knowing this would answer the other question.


You can use something like this

if ($("#formID input:checkbox:checked").length > 0)
    // any one is checked
   // none is checked