Jquery – How to determine whether any checkbox is checked

asp.netjquery

I have some checkboxes in vb.net code.

<tr>
    <td colspan="2">
        <asp:CheckBox ID="chkbxCreateAmendOrg" runat="server" Checked="False" Text="Create/Amend Organisation" />
    </td>
    <td colspan="2">
        <asp:CheckBox ID="chkbxCreateAmendCPUser" runat="server" Checked="False" Text="Create/Amend CP User" />
    </td>
</tr>
<tr>
    <td colspan="2">
        <asp:CheckBox ID="chkbxDeleteOrg" runat="server" Checked="False" Text="Delete Organisation" />
    </td>
    <td colspan="2">
        <asp:CheckBox ID="chkbxDeleteCPUser" runat="server" Checked="False" Text="Delete CP User" />
    </td>
</tr>

I want to give alert to user if they have not selected atleast one. Can i have jquery code for this

Best Answer

You can select all the not checked checkboxes and check the length or size() of the jQuery object:

if ($('input:checkbox:not(:checked)').length > 0) {
  // some checkboxes not checked
}