JSFiddle - React, Tailwind, and code Playground

by kachibito

HTML

<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">
<input type="checkbox" value="1">

CSS

label {display:block;}

JavaScript

$("input[type=checkbox]").click(function(){
    var countchecked = $("input[type=checkbox]:checked").length;

    if(countchecked >= 3) {
        $('input[type=checkbox]').not(':checked').attr("disabled",true);
    }else{
        $('input[type=checkbox]').not(':checked').attr("disabled",false);
    }
});