4.1.5.1 Custom Regular Expression Validation
If the validation technique you need to use can be completed by using regular expression matching, you can define a custom expression as a field validation rule.
var $validate = array(
'login' => array(
'rule' => '/^[a-z0-9]{3,}$/i',
'message' => 'Only letters and integers, min 3 characters'
)
);
var $validate = array('login' => array('rule' => '/^[a-z0-9]{3,}$/i','message' => 'Only letters and integers, min 3 characters'));
The example above checks if the login contains only letters and integers, with a minimum of three characters.
The regular expression in the rule must be delimited by slashes. The optional trailing 'i' after the last slash means the reg-exp is case insensitive.


























