JSFiddle - React, Tailwind, and code Playground

by nnnnnn

HTML

<form id="form1" name="form1">
<input type="checkbox" name = "checkbox-1[]" class="checkbox" value ="1" />
    
    <input type="checkbox" name = "checkbox-1[]" class="checkbox" value ="1" />
    
    <input type="checkbox" name = "checkbox-1[]" class="checkbox" value ="1" />

<input id="test" type="button" value="Test" />
</form>

JavaScript

document.getElementById("test").onclick = function() {
    isCountCheck("Check something");
};

function isCountCheck(helperMsg) {
    var i, len, inputs = document.form1.getElementsByTagName("input");
    for (i = 0, len = inputs.length; i < len; i++) {
        if (inputs[i].type === "checkbox" && inputs[i].checked) return true;
    }
    alert(helperMsg);
    return false;
}