JSFiddle - React, Tailwind, and code Playground

by wZVanG

HTML

<input type="checkbox" id="atrib_1" /><br />
<input type="checkbox" id="atrib_2" /><br />
<input type="checkbox" id="atrib_3" /><br />
<input type="checkbox" id="atrib_4" /><br />
<input type="checkbox" id="atrib_5" /><br />
<input type="checkbox" id="atrib_6" /><br />
<input type="checkbox" id="atrib_7" /><br />
<input type="checkbox" id="atrib_8" /><br />
<input type="checkbox" id="atrib_20" /><br />

JavaScript

var checkboxes = function(fn){
    var i = 0, box
    while(i <= 20) (box = document.getElementById("atrib_" + i++), box && fn.apply(box,[]))
};
 
checkboxes(function(){
    this.onclick = function(){
        var count = 0
        checkboxes(function(){
            this.checked && count++
        })
        checkboxes(function(){
            !this.checked && count >= 5 ? this.disabled = !0 : this.disabled = !1
        })
    }
});