/    Sign up×
Community /Pin to ProfileBookmark

Checkbox validation dependant on radio

How do I make a checkbox validation dependant on radio button?

so:

if [radio1] is clicked;
then [checkbox] must be clicked

else if [radio2] is clicked;
then [checkbox] does not have to be clicked

I tried disabling it but it still gave me the alert

[CODE]
function disable_validation()
{
if(GetElementById(“radio2”).checked)

{
GetElementById(“checkbox”).disabled=true;
}
}[/CODE]

is there another way of saying it so it turns it off?

thanks for helping this noob

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@2AMauthorSep 03.2009 — nevermind.. i figured out a trick

[CODE]
function disable_validation()
{

if(GetElementById("radio2").checked)

//autocheck to suppress alert
GetElementById("checkbox").checked=true;
}[/CODE]


I am anyway hiding it if radio2 is checked:

[CODE]function R2_onclick()
{
disable_validation()
document.getElementById('entire_tr_with_checkbox').style.display = 'none';
}[/CODE]


It works, but is this a decent way of doing it?
×

Success!

Help @2AM 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.20,
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,
)...