Multiple checkbox validation in jquery

Today, We want to share with you multiple checkbox validation in jquery.In this post we will show you jquery validate checkbox at least one, hear for How to validate a form with multiple checkboxes to have atleast one checked we will give you demo and example for implement.In this post, we will learn about multiple checkbox validations in javascript with an example.

jQuery Validation with Multiple Checkboxes

Example 1: index.html

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#btnSubmit").click(function () {
            var checked = $("#tblFruits input[type=checkbox]:checked").length;
            var isValid = checked > 0;
            $("#spnError")[0].style.display = isValid ? "none" : "block";
        });
    });
</script>
</head>
<body>

<table id = "tblFruits" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td><input type="checkbox" value="1" /></td>
        <td>Mango</td>
    </tr>
    <tr>
        <td><input type="checkbox" value="2" /></td>
        <td>Laptop</td>
    </tr>
    <tr>
        <td><input type="checkbox" value="3" /></td>
        <td>Mobile</td>
    </tr>
    <tr>
        <td><input type="checkbox" value="4" /></td>
        <td>Computer</td>
    </tr>
    <tr>
        <td><input type="checkbox" value="5" /></td>
        <td>Iphone</td>
    </tr>
</table>
<br />
<span id="spnError" class="error" style="display: none">Please select at-least one Fruit.</span>
<br />
<input type="button" value="Submit" id = "btnSubmit" />

</body>
</html>

I hope you get an idea about jquery multiselect dropdown with checkbox validation.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Also Read This 👉   automatic image slider in html - How To Create a Slideshow?