CodeIgniter Forums
Form Validation Any One Of 5 Inputs Required - 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: Form Validation Any One Of 5 Inputs Required (/showthread.php?tid=51210)



Form Validation Any One Of 5 Inputs Required - El Forum - 04-24-2012

[eluser]Kebabman[/eluser]
Using the standard CI form validation procedures is it possible to require any one of 5 inputs? For example is it possible to have 5 text areas and for validation to succeed any one of those 5 (or more) can have text in it. The only requirement is that not all of the text areas are empty, if that makes any sense...


Form Validation Any One Of 5 Inputs Required - El Forum - 04-24-2012

[eluser]CroNiX[/eluser]
Sure, you can just use a callback and in the callback function check all 5 fields using $this->input->post(field) and if any one of them has data, it passes the rule.


Form Validation Any One Of 5 Inputs Required - El Forum - 04-24-2012

[eluser]Kebabman[/eluser]
Ah right ok, great. Thanks for the reply, I will look into the specifics of callbacks.


Form Validation Any One Of 5 Inputs Required - El Forum - 04-24-2012

[eluser]Kebabman[/eluser]
All working now, thanks again for the tip!