Click to See Complete Forum and Search --> : how do I validate a radio buton "yes or no" with Javascript.


SeanPaul72
08-07-2003, 06:41 PM
I have a form with about 12 yes or no questions. here's question 1 for example:<tr><td valign=top><i>1</i></td><td valign=top><i>Are there any judgments against you?</i>
<br></td>
<td align=center valign=top><input type=radio name="L230" value="Y"></td>
<td align=center valign=top><input type=radio name="L230" value="N"></td>
</tr>

So the viewer can choose either yes, "Y" or no, "N"

I've tried the following but it doesn't workif(document.lion1003.L230.value = "")
{
alert('Please answer question 1');
document.lion1003.L230.focus();
return false;
}
The submit button is as follows:
Thanks<form action=caddress.php name=lion1003 method=post onSubmit="return DataValSubmit('declaration')">

Exuro
08-07-2003, 06:46 PM
Originally posted by SeanPaul72
I've tried the following but it doesn't workif(document.lion1003.L230.value = "")
{
alert('Please answer question 1');
document.lion1003.L230.focus();
return false;
}

You made one of the most common mistakes in programming ;):

if(document.lion1003.L230.value == "")