Welcome to the Cookbook

loading...

4.1.4.26 url

This rule checks for valid URL formats. Supports http(s), ftp(s), file, news, and gopher protocols.

var $validate = array(
    'website' => array(
        'rule' => 'url'
    )
);
  1. var $validate = array(
  2. 'website' => array(
  3. 'rule' => 'url'
  4. )
  5. );

To ensure that a protocol is in the url, strict mode can be enabled like so.

var $validate = array(
    'website' => array(
        'rule' => array('url', true)
    )
);
  1. var $validate = array(
  2. 'website' => array(
  3. 'rule' => array('url', true)
  4. )
  5. );