the above code will prevent the form from submitting if the checkbox is not checked.
Main Topics
Browse All TopicsI would like to know if there is a way to make a checkbox on a form a required field. I know that normally a checkbox is used to pick an option/selection but I would like to use it as a way to control accountability.
i.e. By selecting this box you agree to XXX....
Thank you,
seamil
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
also, you may want to present a message:
<SCRIPT language='javascript'>
function validate(theForm)
{
var c = theForm.mycheckbox.checked
if ( c == false ) alert("you must check the box!");
return c;
}
</script>
<FORM name='myform' action='whatever.asp' method='post'
onSubmit='return validate(this);'>
<INPUT type='checkbox' name='mycheckbox'>
</form>
you can call it whatever you want inside the function as long as you pass a reference to the form when you call the function. So you can do this:
function validate(theForm)
and use "theForm" in the function, as long as you do this in the form tag:
onSubmit='return validate(this);'>
which is another way of doing this:
onSubmit='return validate(document.formname
If you still have problems, post your code and I will look it over.
Business Accounts
Answer for Membership
by: knightEknightPosted on 2002-06-11 at 13:21:48ID: 7071248
<FORM name='myform' action='whatever' method='post'
onSubmit='return this.mycheckbox.checked;'>
<INPUT type='checkbox' name='mycheckbox'>
</form>