Problem with cakephp validation
I have field in my model whose validation rules is shown below.
'message' => array(
'rule' => '/^[a-z0-9#.,&; ]{2,255}$/i',
'required' => true,
'allowEmpty' => false,
'mes开发者_开发知识库sage' => '(message field contains only a-z0-9#.,&; and is between 2 to 255 characters.).'
),
This works fine. When I add forwardslash(/) to the rule '/^[a-z0-9#.,&;/ ]{2,255}$/i'
or '/^[a-z0-9#.,&;\/ ]{2,255}$/i'
. then it does not work.
I appreciate any help.
Thanks.
That isn't a backslash, it is a forward slash.
So I don't know which slash you want to use, but one of these should work:
'/^[a-z0-9#.,&;\\ ]{2,255}$/i'
or
'/^[a-z0-9#.,&;\/ ]{2,255}$/i'
精彩评论