CodeIgniter Forums
{SOLVED]Conditional Validation - Printable Version

+- CodeIgniter Forums (
+-- Forum: Archived Discussions (
+--- Forum: Archived Development & Programming (
+--- Thread: {SOLVED]Conditional Validation (/thread-29598.html)

{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

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

I think you will have to do something like:
    $this->form_validation->set_rules('field','Field','your rules');

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