I need to ensure that if at least one checkbox (of many) is not ticked, the form wont submit, this is what I have at the moment, I thought it should work:
<script type="text/javascript">
function valthis() {
var checkBoxes = document.getElementsByClassName( 'myCheckBox' );
var isChecked = false;
for (var i = 0; i < checkBoxes.length; i++) {
if ( checkBoxes[i].checked ) {
isChecked = true;
};
};
if ( !isChecked ) {
alert( 'Please, check at least one checkbox!' );
return false;
}
}
</script>
I would appreciate any help I can get!!!
regards, Mason.