FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


check box validation





ptanjun
ive looked everywhere for a script that will make it so that people can not submit a form until they have checked a check box. i've found other form validation codes for text areas and such but nothing for a check box.

thanks in advance.
mathiaus
I can think of two options available to you.

1. let them submit the form but the next page not process it unless the checkbox is checked ie. in php
Code:

$check=$_POST['checkbox'];
if ($check=="") {
echo "You did not agree to the TOS";
}
else {
//other form processes here
}



2. use the code below so the submit button can only be pressed when checkbox is hit
Code:
<form name="form1"><input type="checkbox" onclick="javascript:document.form1.submit.disabled=false">
<input type="submit" name="submit" disabled></form>



Matt Cool
Bondings
I would use them both.
mathiaus
good point. just tried the javascript option and thereare two problems with it

1. pressing the return button works as well in its place
2. checkbox needs to be clicked to make submit appear but if unlicked later the submit button still appears Mad
Related topics
Windows Tips&tricks!
Fantastico could be updated
CHMOD Tutorial
Dynamic PHP Images
WinXP - login
password protecting a directory
Anti Aliasing, What is it?
Boot up Windows XP 60 times faster
Help Please
Remote Desktop Problem
Outlook Express Deleting Attachments !
l killed myspace on my school's network!!!
array check box on php script using $_POST
Simple Form Validation [solved]
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.