{SOLVED]Conditional Validation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: {SOLVED]Conditional Validation (/showthread.php?tid=29598) |
{SOLVED]Conditional Validation - El Forum - 04-14-2010 [eluser]eric cumbee[/eluser] i have a form that is broken up into several sections. some sections only need to be filled out in certain circumstances, mainly if the user checked a check box. im using jquery to hide and show those sections based on the user input. that is working fine. the question i have now, is how do i setup form validation (using the CI form validation) so that if a certain check box is not checked, it will not worry about validating the fields in that form section. {SOLVED]Conditional Validation - El Forum - 04-15-2010 [eluser]Krzemo[/eluser] What about checking states of checkboxes first and then building validation rules for desired fields based on that? {SOLVED]Conditional Validation - El Forum - 04-15-2010 [eluser]adamp1[/eluser] I think you will have to do something like: Code: if($this->input->post('checkbox')) Currently there is no Conditional form validation in CI. That or write a new custom rule to handle the case and possibly patch the Form_validation class. {SOLVED]Conditional Validation - El Forum - 04-15-2010 [eluser]eric cumbee[/eluser] that worked i did not think it would be that simple |