Raphael Caixeta Raphael Caixeta - 7 months ago 38
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.


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