I want to disable submit button if no checkbox are checked in my form. However my function is not working and always allows the submit button to open the next page.
function test(){
var b = false;
var inputs = document.getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++) {
if (inputs[i].checked == true){
return true;
}
}
return false;
}
Form
form name='checkBoxForm' action ='book.php' method='post' onsubmit='return test(this)
Checkbox - note javatest is another working function.
input type='checkbox' id =\"$id\" name='check_list[]' value=\"$seat\" onclick='javatest(this)