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'
精彩评论