![]() |
How to run 2 validations on same form? - 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: How to run 2 validations on same form? (/showthread.php?tid=27518) |
How to run 2 validations on same form? - El Forum - 02-13-2010 [eluser]CodeIgniterNewbie[/eluser] I need to run 2 validation on a single form. See code below. The "signup_basic" are for quick validation routines (e.g. required, min_length, etc.). The "signup_advance" are for validations that take a bit longer to do (e.g. DB calls, web service calls, etc.). I have created 2 groups of validation rules in my config: Code: $config = array( For this example, assume that "signup_advance" requirement for password to be a minimum length of 3 is the validation that takes a long time to execute. In the controller, I call both validations within an if-statement like this: Code: if ($this->form_validation->run("signup_basic") === TRUE AND $this->form_validation->run("signup_advance") === TRUE) { The form seems to pass validation as long as "signup_basic" passes. "signup_advance" is ignored. If I run the validation rules individually, they work well and enforce their respective validation rules. I've tried rearranging the order if the IF conditions as well as the validation rules in config. "signup_advance" seems to be ignored whenever I attempt to compound the validation runs. Is there a way to do this? How to run 2 validations on same form? - El Forum - 02-13-2010 [eluser]SitesByJoe[/eluser] Have you tried running the 2nd IF the 1st passes rather than both together in one conditional check? How to run 2 validations on same form? - El Forum - 02-13-2010 [eluser]CodeIgniterNewbie[/eluser] Yes. Didn't make a difference. |