automatic validations of form fields (server side)
Recently I tried zend framework (the quickstart project) :) and I really liked it.
All the frameworks (zend, cakephp) implements a very nice way of form fields validation. Moreover these validati开发者_如何学JAVAons are so easy to implement that you only have to give the name of the validation that you want to apply.
Like this:
$this->addElement('text', 'email', array(
'label' => 'Your email address:',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array(
'EmailAddress',
)));
Also if any of the input is typed against the validation criteria and submitted, then the remaining form fields values are not cleared at all and proper message is displayed.
This made me think that how shall I create a system similar to this validation criteria. So that it can be easily embedded into a web application which has not been build using the framework.
Ofcourse I can do this in PHP (checking every posted value using functions or classes) but I want to do it the smarter and effecient way just like these frameworks have done.
So does any one know of any library for PHP which is able to do such validations.
I hope I am able to explain my doubt clearly. Any help is greatly appreciated.
Why don't you just include the Zend_Form_Validation library. The idea of ZF is that you can load any libraries you want, you don't have to go through a bootstrap process to use the framework. Just include it and use it.
HTML_QuickForm
精彩评论