I have a zend form where I have a phone number field and you need to check the validator.
I decided to use a regular expression for this. I searched google, but the results that I have do not work.
Can anyone provide me a regex. here is my code:
$phone = new Zend_Form_Element_Text('phone');
$phone->setRequired(true);
$phone->setLabel('Phone :')
->addFilter('StripTags')
->addValidator('NotEmpty', false, array('messages'=>'phone cannot be empty'))
->addFilter('StringTrim')
->addValidator('regex', false, array('/^[0-9 ]+$/','messages'=>'not a valid phone number'))
->addValidator('StringLength', false, array(5, 25, 'messages'=>'phone must be 5-25 character'))
Thanks in advance
source
share