title: codeigniter form validation rules url
body: <p>How can I validate form field which has URL as input value.</p>
  
  <p>I tried with following rules. But it allows the field if the user input a string.</p>
  
  <p><strong>View File:</strong></p>
  
  <pre><code>&lt;?php $data = array(
                      'name'        =&gt; 'com_url',
                      'id'          =&gt; 'com_url',
                      'value'       =&gt; set_value('com_url'),
                      'placeholder' =&gt; $this-&gt;lang-&gt;line('register_com_url'),
                      'class'       =&gt; 'form-control',
                      'maxlength'  =&gt; 100
  
                    );
                    echo form_input($data);
              ?&gt;
  </code></pre>
  
  <p><strong>Config:</strong></p>
  
  <pre><code>array(
      'field'   =&gt; 'com_url',
      'label'   =&gt; 'Com URL',
      'rules'   =&gt; 'trim|required|prep_url'
  )
  </code></pre>
  
  <p>I user prep_url but it adds just http:// in the field but didn't validate the field for URL.</p>
  
  <p>My Field should accept only the following formats:</p>
  
  <blockquote>
    <p><a href="http://www.sample.com" rel="noreferrer">http://www.sample.com</a></p>
    
    <p>www.sample.com </p>
    
    <p><a href="http://sample.com" rel="noreferrer">http://sample.com</a></p>
  </blockquote>
  
  <p>How can I do this? </p>