Hi, how do i make a validation script for a checkbox, I have php require the text fields, but it wont work for a checkbox.
any ideas?
Josh
javascript validation for a checkbox
Re: javascript validation for a checkbox
well, i got something, but it wont work. No matter what I select, yes or no, it always displays the same response.
any ideas
if($t27=="1"){
echo "alert('Thank You for Agreeing to Terms & Conditions');";
// ... checkbox1 has been checked, form processing code here
} else {
echo "alert('Error! You must agree to the terms and conditions!');history.back(-1);"; // ... checkbox1 has NOT been checked, form processing code here
}
This is the html part of the form
Yes
No
any ideas
if($t27=="1"){
echo "alert('Thank You for Agreeing to Terms & Conditions');";
// ... checkbox1 has been checked, form processing code here
} else {
echo "alert('Error! You must agree to the terms and conditions!');history.back(-1);"; // ... checkbox1 has NOT been checked, form processing code here
}
This is the html part of the form
Yes
No
Re: javascript validation for a checkbox
What is the html code on the form?
Nullig
Nullig
Re: javascript validation for a checkbox
if($_POST['input_checkbox_field'] == "on") {
...code here
}
checkboxes will post either "on" or "off" its' weird.
-K
...code here
}
checkboxes will post either "on" or "off" its' weird.
-K
Re: javascript validation for a checkbox
ok, here is the form, I used a script from dynamicdrive.com and it works with a checkbox on their site. But not mine of course. here is the link
http://wareriver.com/clients/fs/form.html
any ideas would be great
thanks
Josh
http://wareriver.com/clients/fs/form.html
any ideas would be great
thanks
Josh
Re: javascript validation for a checkbox
if someone has some code on them for validating a checkbox, I will try that.
Re: javascript validation for a checkbox
Did this work for you?if($_POST['input_checkbox_field'] == "on") {
...code here
}
I think what is meant is
if($_POST['t27'] == "on") {
echo "alert('Thank You for Agreeing to Terms & Conditions');";
// ... checkbox1 has been checked, form processing code here
} else {
echo "alert('Error! You must agree to the terms and conditions!');history.back(-1);"; // ... checkbox1 has NOT been checked, form processing code here
}
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo
--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
--
LinkedIn profile
--
I only speak/write in English so I may not translate well on International posts.
--
Re: javascript validation for a checkbox
..that is what I put, just in fewer words. lol
-E
-E
Last edited by Kayin on Mon May 07, 2007 9:41 pm, edited 1 time in total.
Re: javascript validation for a checkbox
Sorry, Ill try it in the morning. I just made a text field where the person has to type in yes rather than check it. Ill try it, I think that would be better than just a text box.
thanks
Josh
thanks
Josh