lisajv3 Posted March 19, 2019 Share Posted March 19, 2019 I am trying to create a validation for a radio button field. The value of this field could only be one number, but depending on the number they select, I need to loop through multiple fields and validate each field on the form that ends in that number. Below is more detail, but I'm only showing one field. The (i) after the field could be the numbers 1 through 6. I've tried to put this into my code, but I am unable to save it because it is telling me that a ; is missing before my statement. I am able to save my code if I take out both for statements and the ending }. Can someone look at this and tell me where I'm going wrong? Thank you. *============================================== function validate() { errMSG = "" var f = document.forms[0]; var td = getRadioButtonValue(document.forms[0].RAField); for (td = 1; td <= 6; td++) { If (td = 6) { var tdChars ="123456"; } else if (td = 5) { var tdChars = "12345"; } else if (td = 4) { var tdChars = "1234"; } else if (td = 3) { var tdChars = "123"; } else if (td = 2) { var tdChars = "12"; } else { var tdChars = "1"; } } for (i=0; i <= tdChars.length; i++) { if(f.JobGuaranteeDuration(i).selectedIndex<1) { if (errMSG!="") { errMSG += "Select a Guarantee Duration for Roof Contruction(i)\n"; }else { errMSG+="Please correct the following:\n\nSelect a Guarantee Duration for Roof Contruction(i)\n"; } } if (errMSG != "") { alert(errMSG); f.SaveOptions.value = '0'; return false } f.SaveOptions.value = '1'; return true } } *============================================== Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now