function NewRentalForm_Validator(theForm) { submitonce(theForm); var message = "Please do not leave the following fields Blank: "; var len = 0; var name = ""; for (i=0;i<theForm.elements.length;i++) { name = theForm.elements[i].name; len = name.length; if (name.substring(0,4).toUpperCase() == "C2B_" && name.substring(len-4).toUpperCase() == "_REQ" && theForm.elements[i].value.length == 0 ) { message = message + "\n " + name.substring(4,len-4); } } if (message.length > 48) { alert(message); submitenabled(theForm); return (false); } return (true); }Now for radio buttons, I was thinking something along the lines of changing the if statement to be something like:
if (name.substring(0,4).toUpperCase() == "C2B_" && name.substring(len-4).toUpperCase() == "_REQ" && (theForm.elements[i].value.length == 0 || !theForm.elements[i].checked))Of course the preceeding code would make the following radio button cause the error message because one of the options wouldn't be selected
<INPUT type=radio value=male name=c2b_Sex_req> Male <BR> <INPUT type=radio value=female name=c2b_Sex_req> FemaleIf I was writing the name of the options etc, I know I could hardcode and make sure that one option of the group was checked. I'm having a problem because I won't know what the names of these option groups might be.