Raphael Caixeta Raphael Caixeta - 1 year ago 75
PHP Question

Validating single form field with CodeIgniter

Is there a quick way to validate a single form field with CodeIgniter to see whether or not that field matches a set of rules? There's the $this->form_validation->run();, but that will return either TRUE or FALSE for the whole form, and that's just not what I'm looking for. For example, if I only wanted to check if the email was valid, checking the whole form is not going to get me the result I'm looking for.

I looked through the documentation but couldn't find anything like $this->form_validation->run(); that accepts one parameter and returns TRUE or FALSE if it's valid.

Answer Source

The form_validation class supports groups so you can define a group as email and run it like this $this->form_validation->run('email');

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download