Welcome Guest, Not a member yet? Register   Sign In
Form Validation


I looked through the documentation for the form validation library and I'm wondering if there's a way you can check if a field is valid instead of just the whole form.

For example, if I want the whole form to be validated I would do

What if I just wanted to see if $_POST['email'] is valid though? How do I go about doing that?

Thanks for any help in advance!

In system/application/MY_Form_validation.php
class MY_Form_validation extends CI_Form_validation {
    function clear_rules() {
        $this->_field_data  = array();
        $this->_error_array = array();
        $this->_error_messages = array();

In your controller set the rules to check $_POST['email'] and run the validation. If you then need to run a different set of validation, call clear_rules() and set the new validation rules.

It would be nice if $this->form_validation->run($_POST['email']); worked haha

Theme © iAndrew 2016 - Forum software by © MyBB