Getting a count of checked items in a CheckBoxList

The following function uses JQuery and will get the number of checked items in a CheckBoxList.

<script type="text/javascript">
    function checkBoxListCount() {
        var count = $('input[type=checkbox][id*=CheckBoxListId]:checked').length;
        if (count == 0) {
            return false;
        }
        else {
            return true;
        }            
    }
</script>

Where [id*=CheckBoxListId] is change CheckBoxListId to the name of CheckBoxList.

Comments are closed.