Jump to content

Validate Checkbox Help Please


magnolia

Recommended Posts

I have added a checkbox:

 

<div class='container'>

<label for='terms_and_conditions' >I have read and agree to the Terms & Conditions.*</label>

<input type='checkbox' id='Terms and Conditions' name='terms_and_conditions' value='Yes'>

<span id='contactus_terms_and_conditions_errorloc' class='error'></span>

<br/>

</div>

 

I have validations at the bottom of the same page like so:

 

frmvalidator.addValidation("terms_and_conditions","shouldselchk=yes","Please agree to the Terms and Conditions.");

 

My server is ignoring all of validations like the one above, but is responding to all the validations in this file except for the checkbox: include/fgcontactform.php

 

//terms and conditions validations

if(isset($_POST['terms_and_conditions']))

{

$this->add_error("Please agree to the Terms and Conditions");

$ret = false;

}

 

 

Can anyone please help? I have been searching for a week. I got the form from html-form-guide.com

Edited by magnolia
Link to comment
Share on other sites

Checkboxes are not POSTed unless they are checked. So the "terms_and_conditions" element will not be in the POST array unless the user checked the box. You need to change the IF statement to

 

if (! isset($_POST['terms_and_conditions']))

Link to comment
Share on other sites

Woohoo! So far so good. "not POSTed" means ! Now I know. Thank you so very much DavidAM. Hey you don't have a $ or ! in front of your name.

 

My server is tricky. When I first upload things they work, then things change and this is one of those things.

 

Thank you for the help.

Link to comment
Share on other sites

Glad I could help. Welcome to the world of programming. Where the only thing that is constant, is change.

 

If that solves your problem, go ahead and click the "Mark Solved" button at the top of the page.

 

Hmm, if I put a "!" in front of my name, I wouldn't know who I am. !DavidAM

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.