Hi
I need to validate whether or not a radio button has been selected using javascript.
I have been using this:
[CODE]function valbutton(thisform) {
myOption = -1;
for (i=0; i<thisform.radiobutton.length; i++) {
if (thisform.radiobutton[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert(“Please Select one of the Radio Buttons”);
return false;
}
thisform.submit(); // this line submits the form after validation
}
This works fine, but I need something that will be able to do the same with radio buttons that are named as an array. Example, my set of radio buttons that I want to validate are all called ” radiobutton[2]”.
I tried changing the above script to use this new name, but it no longer works.
Anyone know how I can do this?
Thanks