bba bba - 1 year ago 107
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.

Answer Source

You can use something like this

if ($("#formID input:checkbox:checked").length > 0)
    // any one is checked
   // none is checked
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download