Tuesday, August 14, 2018

How to require at least one checkbox

Here is your script:


<script>
            $(document).ready(function () {
                $('#checkBtn').click(function() {
                  checked = $("input[type=checkbox]:checked").length;

                  if(!checked) {
                    alert("You must check at least one record.");
                    return false;
                  }

                });
            });
</script>
            

Add this to your submit button:

 id="checkBtn"