/    Sign up×
Community /Pin to ProfileBookmark

radio buttons help!

When I don’t press a radio button it comes up with an alert saying I need to which is what I want but when I do press one it still comes up with that alert, How do I stop that from happening?

IN FUNCTION FIELDCHECK I HAVE WRITTEN:
case “radio_hidden”:
if (fld.value != “1”)/* radio male or female button should be checked*/
{
fld.valid = true;
}
break;
IN MY FUNCTION VALIDATE FORM I HAVE WRITTEN:
if (frm.radio_hidden.valid == false)
{
report_text += ” You must click a radio button male or female.nn”
}

IN MY HTML CODE THIS IS WHAT I HAVE WRITTEN:
<br><u>Select Your gender:</u><br>

<input type=”radio” name=”rad” value=”” onchange=”radio_hidden.value = 1;”> Male

<br>
<input type=”radio” name=”rad” value=”” onchange=”radio_hidden.value = 1;”> Female
<br>
<input name=”radio_hidden” value=”1″ type=”hidden”>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ReisNov 01.2009 — Something like this:

[CODE]<script>
function validate() {
if(document.getElementById('male').checked == false && document.getElementById('female').checked == false) {
alert('you must check a gender!');
return false;
}

return true;
}
</script>
IN MY HTML CODE THIS IS WHAT I HAVE WRITTEN:
<br><u>Select Your gender:</u><br>

<form name="form1" onsubmit="return validate();">
<input type="radio" name="rad" id="male" value="male" /> Male
<br>
<input type="radio" name="rad" id="female" value="female" /> Female
<br>
<input type="submit" value="send" />
</form>[/CODE]
×

Success!

Help @tilly01 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.7,
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,
)...