magnolia Posted November 30, 2012 Share Posted November 30, 2012 (edited) 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 November 30, 2012 by magnolia Quote Link to comment https://forums.phpfreaks.com/topic/271423-validate-checkbox-help-please/ Share on other sites More sharing options...
DavidAM Posted December 1, 2012 Share Posted December 1, 2012 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'])) Quote Link to comment https://forums.phpfreaks.com/topic/271423-validate-checkbox-help-please/#findComment-1396594 Share on other sites More sharing options...
magnolia Posted December 3, 2012 Author Share Posted December 3, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/271423-validate-checkbox-help-please/#findComment-1397041 Share on other sites More sharing options...
DavidAM Posted December 3, 2012 Share Posted December 3, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/271423-validate-checkbox-help-please/#findComment-1397055 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.