Hi,
I need help with Javascript validating input in some fields in my form.
-
When a user chooses alt1 from a radiobutton field (service) a serviceAllt1 subform will be opened and the fieldA & fieldB must be entered.
-
When a user chooses alt2 from a radiobutton field (service) a serviceAllt2 subform will be opened and the fieldC & fieldD must be entered.
-
When a user chooses alt3 from a radiobutton field (service) a serviceAllt3 subform will be opened and the fieldE & fieldF must be entered.
Note! I have a Notes submit button not JavaScript submit code.
How to make this work fine? Please I need detailed help, I tried many times but nothing happen.
I appreciate any help!
//Rebecka
Subject: Help!! Special input validation with JavaScript
hi
you can use this code on radion button click event
function valbutton(thisform) {
// place any other field validations that you require here
// validate myradiobuttons
myOption = -1;
for (i=thisform.myradiobutton.length-1; i > -1; i–) {
if (thisform.myradiobutton[i].checked) {
myOption = i;
}
}
if (myOption == -1) {
alert(“You must select a radio button”);
return false;
}
alert("You selected button number " + myOption
// place any other field validations that you require here
thisform.submit(); // this line submits the form after validation
}
u can test like this by
if(thisform.myradiobutton[myOption].value==“ALt1”
{
something to happen
}
if
Subject: Need more help!! Special input validation with JavaScript
thanks, it did not work… Im very new in JavaScript, hope for more help solving this issue…