Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to limit the number of selected checkboxes

(function ($) {
  $(document).ready(function () {
    $(document).on("change", ".pricing-levels-3 input", function () {
      var numberOfChecked = $(".pricing-levels-3 input:checkbox:checked").length;
      if (numberOfChecked >= 2) {
        $(".pricing-levels-3 input:not(:checked)").prop("disabled", true);
      } else {
        $(".pricing-levels-3 input:not(:checked)").removeAttr("disabled", true);
      }
    });
  });
})(jQuery);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #limit #number #selected #checkboxes
ADD COMMENT
Topic
Name
5+8 =