开发者

Problem with cakephp validation

开发者 https://www.devze.com 2023-02-14 20:19 出处:网络
I have field in my model whose validation rules is shown below. \'message\' => array( \'rule\' => \'/^[a-z0-9#.,&; ]{2,255}$/i\',

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'

0

精彩评论

暂无评论...
验证码 换一张
取 消