lazyrunner50
Programmer
Hey. I am having a problem with my form submitting even though I do not want it to. I am using a script that checks to see if three radio buttons are selected. If they are all selected, it will go on to the processing page, otherwise it is supposed to alert the user and stay on the same page. As it is, it will alert the user and when they click ok, it will take them to the processing page.
Here's my script:
Here's the calling code:
P.S. I tried to do this whole function with one for and if combination (instead of three), but I couldn't get it to work for some reason...so if anyone has any suggestions I'd really appreciate it.
Here's my script:
Code:
function validForm(signupForm)
{
theReturnValue = true;
radioNumber1 = -1
for (i=0; i<signupForm.radioGroup1.length; i++)
{
if (signupForm.radioGroup1[i].checked)
{
radioNumber1 = i
}
}
if(radioNumber1==-1)
{
alert ("You must fill out the form completely")
signupForm.radioGroup1.focus()
theReturnValue = false;
}
radioNumber2 = -1
for (i=0; i<signupForm.radioGroup2.length; i++)
{
if (signupForm.radioGroup2[i].checked)
{
radioNumber2 = i
}
}
if(radioNumber2==-1)
{
alert ("You must fill out the form completely")
signupForm.radioGroup2.focus()
theReturnValue = false;
}
radioNumber3 = -1
for (i=0; i<signupForm.radioGroup3.length; i++)
{
if (signupForm.radioGroup3[i].checked)
{
radioNumber3 = i
}
}
if(radioNumber3==-1)
{
alert ("You must fill out the form completely")
signupForm.radioGroup3.focus()
theReturnValue = false;
}
return theReturnValue;
}
Code:
<form name="feedbackForm" action="processFeedback.asp" method="post" onSubmit="return validForm(this)">
P.S. I tried to do this whole function with one for and if combination (instead of three), but I couldn't get it to work for some reason...so if anyone has any suggestions I'd really appreciate it.