Welcome Guest, Not a member yet? Register   Sign In
Validation, either or
#1

[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?
#2

[eluser]Colin Williams[/eluser]
You just need a humble little IF control statement:

Code:
$rules['phone1'] = 'required';
if ( ! $this->input->post('phone1'))
{
   unset($rules['phone1']
   $rules['phone2'] = '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.
#3

[eluser]Hamilogre[/eluser]
Aaaahhh, makes total sense! Thanks, I'll try it out.




Theme © iAndrew 2016 - Forum software by © MyBB