i make a form in zend framework2 but i cannot add capital letter how i validate capital A to Z in zf2?here is my code:
if(!$this->inputFilter)
{
$inputFilter = new InputFilter();
$factory = new InputFactory();
$inputFilter->add($factory->createInput(array(
'name' => 'username',
'required'=>true,
'filters'=> array(
array('name'=>'StripTags'),
array('name'=>'StringTrim')
),
'validators'=>array(
array('name'=>'Regex',
'options'=> array(
'pattern' => '/^[a-z0-9_.-]{1,50}+$/' // contain only a to z 0 to 9 underscore, hypen and dot and min 1 characters max 50
)
)
)
)));
Change your pattern to be case-insensitive by adding the i
modifier:
/^[a-z0-9_.-]{1,50}+$/i
Or explicitly allow capital letters:
/^[a-zA-Z0-9_.-]{1,50}+$/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.