Here i have explained how to Limit Checkbox Selection in jQuery.

Step 1) Add HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Limit Checkbox Selection in jQuery </title>
<script src=""></script>
    $(document).ready(function () {
        $('input[type=checkbox]').click(function (e) {
            var num_checked = $("input[type=checkbox]:checked").length;
            if (num_checked > 3) {
                alert("Sorry, you can't select more than 3 Checkboxes!");
                $('checked', false);

<h1> Limit Checkbox Selection in jQuery</h1>

<div> <b>Select Checkboxes</b> <small>(maximum 3 allowed)</small>   <br /><br /> </div>

<label> <input type="checkbox"> Running </label>
<label> <input type="checkbox">Boxing </label>
<label> <input type="checkbox"> Sleeping</label>
<label> <input type="checkbox"> Swimming </label>


Add Comments