5

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

1 Answer 1

4

RTFM :-)

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.