/    Sign up×
Community /Pin to ProfileBookmark

checkbox validation help plz

hi guys,
i need check box validation. if i didn’t check it then it must alert error “please agree term and condition”.
if it checked it it should not return and thing.
i m using following code
function checkBoxes(fld)
{
if (!fld.checked)
{
error =”Please agreed to the Terms and Conditions!”;
return error;
}
return true;
}

it works well. when i didnt check it return error.but if i check it. it again lert “true”.
i need to skip return true.if i check it it didnt show alert.
any one know how to?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Ay__351_eJun 24.2008 —  <br/>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta content="text/html; charset=UTF-8"
http-equiv="content-type"&gt;
&lt;title&gt;&lt;/title&gt;
&lt;script type="text/javascript"&gt;

function checkBoxes(fld)
{
if (!fld.checked)
{
alert("Please agreed to the Terms and Conditions!");
return false;
}
return true;
}
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;input type="checkbox" name="c" onclick="checkBoxes(this)"&gt;
&lt;br&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

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