Regx validation in Zend Framework

Regx validation in Zend Framework

Here showing Email validation.

 $email = new Zend_Form_Element_Text(’email_address’);
$email->setLabel(‘Email Address:’)
->addValidators(
array(
array(‘regex’, false,
array(‘pattern’ => ‘/^.+@.+[.].{2,}$/i’))))
->setRequired(true)
->setAttribs(array(‘id’ => ’email_address’, ‘class’ => ‘input-text-field’))
->addErrorMessage(‘please enter a valid email address’);