Hi guys i am creating a validation for checking if the user has selected at least one stand by checking it, if no stands are selected then an alert box should display telling the user to select at least one stand. my javascript function is triggered onsubmit.
my code is
function checkstanddocument(){
ab = document.getElementById("repo_document_form").elements[['stands[]']];
for (var i = 0; i <= ab.length; i++){
if (ab[i].checked == true){
return true
}
}
alert("Please select at least one stand");
return false
}
I thought the system will only proceed to the alert box if no checkbox is checked, but it doesn't even reach the alert box even if you checked or did not check it, and i want it to display an error if there is no checkbox checked.. can anyone tell me what have i done wrong.please cause it looks 110% correct to me.