![]() |
Validation, either or - 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: Validation, either or (/showthread.php?tid=10903) |
Validation, either or - El Forum - 08-17-2008 [eluser]Hamilogre[/eluser] Hi, I'm looking for a way to force validation on one field, OR another field. I have a primary phone number field, and a secondary phone number field. I want one of them to be required. How can I accomplish this? Validation, either or - El Forum - 08-17-2008 [eluser]Colin Williams[/eluser] You just need a humble little IF control statement: Code: $rules['phone1'] = 'required'; Note that the condition to match might be more complex than that. You could otherwise have a check_phone_no() callback that essentially does the same thing... might be a little cleaner that way. Validation, either or - El Forum - 08-17-2008 [eluser]Hamilogre[/eluser] Aaaahhh, makes total sense! Thanks, I'll try it out. |