I am unable to make Zend_Validate_EmailAddress show only 1 error message when the user enter invalid email address. The code is
$email = new Zend_Form_Elemen
You can put this one line at end of isValid() funciton but before return false.
$this->_messages = array($this->_messageTemplates[self::INVALID]);
like this:
public function isValid($value)
{
if (!is_string($value)) {
$this->_error(self::INVALID);
return false;
}
$matches = array();
$length = true;
$this->_setValue($value);
// Split email address up and disallow '..'
if ((strpos($value, '..') !== false) or
(!preg_match('/^(.+)@([^@]+)$/', $value, $matches))) {
$this->_error(self::INVALID_FORMAT);
return false;
}
$this->_localPart = $matches[1];
$this->_hostname = $matches[2];
if ((strlen($this->_localPart) > 64) || (strlen($this->_hostname) > 255)) {
$length = false;
$this->_error(self::LENGTH_EXCEEDED);
}
// Match hostname part
if ($this->_options['domain']) {
$hostname = $this->_validateHostnamePart();
}
$local = $this->_validateLocalPart();
// If both parts valid, return true
if ($local && $length) {
if (($this->_options['domain'] && $hostname) || !$this->_options['domain']) {
return true;
}
}
$this->_messages = array($this->_messageTemplates[self::INVALID]); // ===========By Jagdish Ram JPK --DS-----------
return false;
}