Hi,
 
I want to add email id validation such that email id must be of same domain not other domain.
 
For this I have written below code - 
 
 
        $this->load->library('grocery_CRUD');        
        $crud = new grocery_CRUD();
        $crud->set_theme('datatables');
        $crud->set_table('ci_users');
        $crud->set_subject('User');
        $crud->fields('empcode', 'firstname','lastname','email','password');
        $crud->required_fields('empcode', 'firstname', 'email', 'password');
       
        $crud->set_rules('email', 'Email', 'validate_emailid');
 
and I have defined "validate_emailid" function in same controller like below -
 
       function validate_emailid($email)
       {
               $str = explode("@",$str);       
               if($str[1]=='teamlease.com')
              {
                                echo $this->form_validation->set_message("validate_emailid","Other domain Email id are not allowed ");
                                return FALSE;
              }        
        }
 
but I am getting below error 
"Unable to access an error message corresponding to your field name Email.(validate_emailid)".
 
Can you guys help me to resolve this issue.Thanks in advance.