我正在使用zend。我从models / form / settings.php
中获取了代码$top_menu_font_sizeNotEmpty = new Zend_Validate_NotEmpty();
$top_menu_font_sizeNotEmpty->setMessage('Please enter top menu font size.');
$top_menu_font_size = new Zend_Form_Element_Text('top_menu_font_size', array(
'label' => 'Top Menu Font Size :',
'class' => 'text-size password',
'value'=> $data[0]['top_menu_font_size'],
'cols' => '35',
'rows' =>'4',
'required' => true,
'validators' => array(
array($top_menu_font_sizeNotEmpty, true),
),
'decorators' => $this->requiredElementDecorators,
'description' => '<p>Font Size should have the value between 10 - 15</p>',
));
$this->addElement($top_menu_font_size);
在上面的文本框中,我想验证数字介于10到15之间的文本框。 如何以zend形式验证值?
答案 0 :(得分:3)
$top_menu_font_size->addValidator(new Zend_Validate_Between(array('min' => 10, 'max' => 15)););