email - Zend Framework: How to add a custom validation rule in Zend Form? -


i have created zend form, works fine along validations.

is there anyway can add custom validation within form email address, example want set validation check if email address supplied user hotmail, want accept hotmail email addresses.

<?php class application_form_registrationform extends zend_form{      public function init(){          $firstname = $this->createelement('text', 'firstname');         $firstname->setlabel('firstname: ')                 ->setrequired(true);          $lastname = $this->createelement('text', 'lastname');         $lastname->setlabel('lastname: ')                 ->setrequired(true);          $email = $this->createelement('text', 'email_address');         $email->setlabel('email address: ')                 ->setrequired(true);          $register = $this->createelement('submit', 'register');         $register->setlabel('create new account')                 ->setignore(true);          $this->addelements(array(             $firstname, $lastname, $email, $register         ));         }  }  ?> 

any appreciated.

class mylib_validate_uniqueemail extends zend_validate_abstract {     const not_hotmail = 'nothotmail';     protected $_messagetemplates = array(         self::not_hotmail => "'%value%' not hotmail email address."     );      public function isvalid($value)     {         $valuestring = (string) $value;          $this->_setvalue($valuestring);          $email = explode('@',$value);          if (!substr_count($email[1],'hotmail') ) {             $this->_error(self:not_hotmail);             return false;         }          return true;     } } 

this validate class needed added in form.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -