开发者

sfValidatorRegex not working

开发者 https://www.devze.com 2023-03-11 01:39 出处:网络
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

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

精彩评论

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