/    Sign up×
Community /Pin to ProfileBookmark

how do I validate a radio buton "yes or no" with Javascript.

I have a form with about 12 yes or no questions. here’s question 1 for example:

[code=php]<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>[/code]

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

I’ve tried the following but it doesn’t work

[code=php]if(document.lion1003.L230.value = “”)
{
alert(‘Please answer question 1’);
document.lion1003.L230.focus();
return false;
}[/code]

The submit button is as follows:
Thanks

[code=php]<form action=caddress.php name=lion1003 method=post onSubmit=”return DataValSubmit(‘declaration’)”>[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ExuroAug 07.2003 — [i]Originally posted by SeanPaul72 [/i]

I've tried the following but it doesn't work[code=php]if(document.lion1003.L230.value = "")
{
alert('Please answer question 1');
document.lion1003.L230.focus();
return false;
}[/code]
[/QUOTE]


You made one of the most common mistakes in programming ?:
<i>
</i>if(document.lion1003.L230.value =[COLOR=red]=[/COLOR] "")
×

Success!

Help @SeanPaul72 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...