开发者

sfValidatorRegex not working

I am trying validate a username field on a register form so that a username can only be made up of letters. However, when I use the sfValidatorRegex(), it always returns invalid ("johnny" will return invalid, as does "JoHnNy"). Here's the code I'm using:

// From RegisterForm.class.php

$this->validatorSchema['username'] = new sfValidatorRegex(
  ar开发者_运维知识库ray(
    'pattern' => '[A-Za-z]',
  ),
  array(
    'invalid' => 'only lowercase letters',
  )
);

What am I missing?


Didn't understand whether you wanted lower or uppercase but try:

Only lowercase: '/^[a-z]*$/'

Lower or uppercase: '/^[A-z]*$/i'

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜