title: CodeIgniter form validation rules for checkbox
body: <p>I've a form with checkbox for accepting TOS. The problem is I need to add custom error for this checkbox,</p>
  
  <pre><code>    &lt;form&gt;
  
      &lt;input type="text" name="fname" placeholder="Name" /&gt;&lt;?php echo form_error('fname') ?&gt;
      &lt;input type="text" name="email" placeholder="Email" /&gt;&lt;?php echo form_error('email') ?&gt;
      &lt;input type="text" name="password" placeholder="Password" /&gt;&lt;?php echo form_error('password') ?&gt;
  
      &lt;input type="checkbox" name="accept_terms" value="yes" /&gt; Accept TOS&lt;br&gt;
      &lt;?php echo form_error('accept_terms') ?&gt;
  
      &lt;/form&gt;
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php 
  
   $this-&gt;form_validation-&gt;set_rules('fname','First Name','trim|required|xss_clean');
   $this-&gt;form_validation-&gt;set_rules('email','Email','trim|required|xss_clean|valid_email');
   $this-&gt;form_validation-&gt;set_rules('password','Password','trim|required|xss_clean');
   $this-&gt;form_validation-&gt;set_rules('accept_terms','TOS','trim|required|xss_clean'); // Need to add custom error message 
  
  if ( $this-&gt;form_validation-&gt;run() === TRUE ) {
  
  }else{
  
  }
  ?&gt;
  </code></pre>
  
  <p>When the user does not select TOS, Then I have to say </p>
  
  <blockquote>
    <p>Please read and accept our terms and conditions.</p>
  </blockquote>
  
  <p>Note: I've added <code>form_error</code> function to display individual errors</p>