I’m modifying a form. The form has a field which originally had two possible values set by a pair of radio buttons. I have added three more radio buttons for a total of five. All buttons have the same name and the following values “m, f, a, b, c.”
The validation script is
[CODE]function check_radio(field_name, message) {
var isChecked = false;
if (form.elements[field_name] && (form.elements[field_name].type != “hidden”)) {
var radio = form.elements[field_name];
for (var i=0; i<radio.length; i++) {
if (radio[i].checked == true) {
isChecked = true;
break;
}
}
if (isChecked == false) {
error_message = error_message + “* ” + message + “n”;
error = true;
}
}
}
The problem is that the error message is thrown if any of the three new radio buttons is checked; only checking one of the original two buttons evaluates to a button being checked.
I assume the radio.length property should automatically increase with the additional buttons, but that does not seem to be happening.
Am I missing something?
1) How can I have the page display the radio.length property so I can confirm my suspicions?
2) If it is seeing only two buttons, how can I fix it?
TIA