Magento 1.9 – Server Side Validation of Form

magento-1.9validation

How to validate all form field

 if (!Zend_Validate::is($this->getRequest()->getPost('product[name]'), 'NotEmpty')) {
            $error = true;
            Mage::getSingleton('core/session')->addError(Mage::helper('example')->__('Please enter product name'));
        }

        if (!Zend_Validate::is($this->getRequest()->getPost('product[description]'), 'EmailAddress')) {
            $error = true;
            Mage::getSingleton('core/session')->addError(Mage::helper('example')->__('Please enter Email'));
        }

Using this code i am validate NotEmpty and EmailAddress but also i want to validate only number any other form validation so which class is use for all that

Best Answer

RTFM :-)

For numbers: Zend_Validate_Digits so Zend_Validate::is($value, 'Digits')

http://framework.zend.com/manual/1.12/en/zend.validate.set.html

Related Topic