How to verify email address using the Zend Email Validator

Zend framework provides some nice validators to validate the data input by your visitor/customer. If you want you can write your own custom validator and use it in your code. The one I would like to discuss today is the Zend Email Validator which is really wonderful in that you don’t need to write any JavaScript code to validate the email address. You just need to add the Zend Email Validator to the form element and it will take care of the rest.

Take a look at the following form element against which I have added the Zend Email Validator

$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email Address')
	->addValidator(new Zend_Validate_EmailAddress(
			array('domain' => true)

The above code will check the domain part of the email address provided by the customer.

Once the visitor tries to enter invalid email address then the system will flag the error message. Please see below


Leave a Comment