Thursday, April 23, 2015

ASP.NET CheckBoxList Operations with jQuery - Max Selection Limit

$("[id*=CheckBoxList1] input:checkbox").change(function () {
          var maxSelection = 3;
          if ($("[id*=CheckBoxList1] input:checkbox:checked").length > maxSelection) {
              $(this).prop("checked", false);
              alert("Please select a maximum of " + maxSelection + " items.");
          }
      })

No comments:

Post a Comment