Search
 
SCRIPT & CODE EXAMPLE
 

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);
Comment

Limit number of selected chekboxes

var limit = 3;
$('input.single-checkbox').on('change', function(evt) {
   if($(this).siblings(':checked').length >= limit) {
       this.checked = false;
   }
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: atoi javascript 
Javascript :: bitcoin prices in javascript 
Javascript :: react native fetch response code 
Javascript :: react state field declaration 
Javascript :: qr code terminal npm 
Javascript :: how to strip html tags in javascript 
Javascript :: react setstate concat string 
Javascript :: Alpine.js: button using @click function not working 
Javascript :: count duplicate array javascript 
Javascript :: vue js filter 
Javascript :: discord js invite to channel 
Javascript :: react date range 
Javascript :: box shadow generador react native 
Javascript :: class component in react 
Javascript :: electron in webpack 
Javascript :: on close tab react native web 
Javascript :: getting cannot call a class as a function 
Javascript :: factorial program in javascript 
Javascript :: mapStateProps 
Javascript :: req.params 
Javascript :: apollo client mutation without component 
Javascript :: load js 
Javascript :: leaflet update marker icon 
Javascript :: uuid react native expo 
Javascript :: class in javascript 
Javascript :: how to decode jwt token client side 
Javascript :: js indexof string 
Javascript :: jest always pass async await 
Javascript :: Vowel Count 
Javascript :: inline styling js 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =