phpretard Posted July 26, 2009 Share Posted July 26, 2009 I am validating a form with PHP and it contains check boxes, text, radios etc... The short logic is: -At least one check box has to be checked -At least one radio has to be ticked -And one text box has to be filled If I check a box and tick a radio but do not fill in the text box it validates fine but the check box becomes "un-checked" afterwards. So my question is what is the recommended way keep check boxes checked and radios ticked while validating the rest of the form? I know the hard way to do it but I was hoping for some advise on it. <input type="checkbox" name="referred[]" value="Internet" /> Internet <input type="checkbox" name="referred[]" value="Radio" /> Radio <input type="checkbox" name="referred[]" value="Television" /> Television <input type="checkbox" name="referred[]" value="Billboard" /> Law Talk <input type="checkbox" name="referred[]" value="" /> Billboard <input type="checkbox" name="referred[]" value="Newspaper" /> Newspaper <input type="checkbox" name="referred[]" value="Phone Book" /> Phone Book <input type="checkbox" name="referred[]" value="Attorney Referral" /> Attorney Referral <input type="checkbox" name="referred[]" value="Friend" /> Friend Thanks. Quote Link to comment Share on other sites More sharing options...
vineld Posted July 26, 2009 Share Posted July 26, 2009 If you print the check boxes dynamically it will be easier. You could store the checked boxes in a hidden input field as well and use javascript upon body load. Validating on the client side might be an idea too if you don't really mind not maintaining the checked boxes for that very little clique that do not use javascript. Quote Link to comment 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.