Friday, January 4, 2013

Sex & Zend: Zend framework form input fields validator

zend framework form add validator




http://framework.zend.com/manual/1.12/en/zend.form.elements.html

->addValidator('Regex'falsearray('/^[a-z0-9]{6,}$/i'))




If failing a particular validation should prevent later validators from firing, pass booleanTRUE as the second parameter:
  1. $element->addValidator('alnum'true);
If you are using a string name to add a validator, and the validator class accepts arguments to the constructor, you may pass these to the third parameter ofaddValidator() as an array:
  1. $element->addValidator('StringLength'falsearray(620));
Arguments passed in this way should be in the order in which they are defined in the constructor. The above example will instantiate the Zend_Validate_StringLenth class with its $min and $max parameters:
  1. $validator = new Zend_Validate_StringLength(620);





XXXXXXXXXXXXXXXXX

Its addValidatorS (multiple validators):
$this->addElement('text', 'firstname', array(
                          'label'      => 'Your first name:',
                          'required'   => true,
              'validators' => array(
                  array('regex', false, array(
                  'pattern'   => '/[^<>]/i',
                  'messages'  =>  'Your first name cannot contain those characters : < >'))
              )
));

1 comment:

  1. Gold & titanium stud earrings and aplos (Gold & platinum)
    The best titanium wood stoves gold titanium grey bracelet design made from the best titanium steel. titanium iv chloride The gold core is crafted of titanium mens titanium braclets and its mens titanium wedding bands core is

    ReplyDelete