title: Adding custom callback to Codeigniter Form Validation
body: <p>I want to limit my registration to emails with @mywork.com I made the following in My_Form_validation.</p>
  
  <pre><code>public function email_check($email)
      {
          $findme='mywork.com';
          $pos = strpos($email,$findme);
          if ($pos===FALSE)
          {
              $this-&gt;CI-&gt;form_validation-&gt;set_message('email_check', "The %s field does not have our email.");
              return FALSE;
          }
          else
          {
              return TRUE;
          }
      }
  </code></pre>
  
  <p>I use it as follows. I use CI rules for username and password and it works, for email it accepts any email address. Any I appreciate any help.</p>
  
  <pre><code>function register_form($container)
      {
  ....
  ....
  
  / Set Rules
  $config = array(
  ...//for username
  // for email            
      array(
    'field'=&gt;'email',
    'label'=&gt;$this-&gt;CI-&gt;lang-&gt;line('userlib_email'),
    'rules'=&gt;"trim|required|max_length[254]|valid_email|callback_email_check|callback_spare_email"
     ),
  ...// for password
   );
  
  $this-&gt;CI-&gt;form_validation-&gt;set_rules($config);
  </code></pre>