JSFiddle - React, Tailwind, and code Playground

by stodolaj

HTML

<table id="CheckBoxList1">
    <tr>
        <td><input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" value="One" /><label for="CheckBoxList1_0">One</label></td>
    </tr><tr>
    <td><input id="CheckBoxList1_1" type="checkbox" name="CheckBoxList1$1" value="Two" /><label for="CheckBoxList1_1">Two</label></td>
    </tr><tr>
    <td><input id="CheckBoxList1_2" type="checkbox" name="CheckBoxList1$2" value="Three" /><label for="CheckBoxList1_2">Three</label></td>
    </tr>
</table>
<table id="CheckBoxList2">
    <tr>
        <td><input id="CheckBoxList2_0" type="checkbox" name="CheckBoxList2$0" value="Four" /><label for="CheckBoxList2_0">Four</label></td>
    </tr><tr>
    <td><input id="CheckBoxList2_1" type="checkbox" name="CheckBoxList2$1" value="Five" /><label for="CheckBoxList2_1">Five</label></td>
    </tr><tr>
    <td><input id="CheckBoxList2_2" type="checkbox" name="CheckBoxList2$2" value="Six" /><label for="CheckBoxList2_2">Six</label></td>
    </tr>
</table>
<input type="button" id="btnSubmit" value="Submit" />

JavaScript

$(function() {
    function hasBoxesChecked(id) {
      return $(":checkbox:checked", document.getElementById(id)).length > 0;
    }
    $("#btnSubmit").click(function() {
        alert(hasBoxesChecked("CheckBoxList1"));
        alert(hasBoxesChecked("CheckBoxList2"));
    });
});