Old time CF guy needing to do some client side form validation.
I have a form that creates some dynamic SELECT fields that are like named. CriteriaID1, CriteriaID2 etc.
I can hard code the form and it works as expected. When I try to make it dynamic I am obviously missing something and would like a quick, swift kick in the head to right me.
The working code is:
if ( !checkSelect(form.CriteriaID1) ) {
errors[errors.length] = “You must answer Criteria 1.”;
}
function checkSelect(select){
return (select.selectedIndex > 0);
}
non working dynamic code
var jsCriteria = 3;
for (var i=1; i <= jsCriteria; i++) {
if ( !checkSelect(form.CriteriaID[i]) ) {
errors[errors.length] = “You must answer Criteria [i].”;
}
}
function checkSelect(select){
return (select.selectedIndex > 0);
}
I appreciate your help.
Kev