Home » HTML » HTML_QuickForm » Bug #1896
validation broken for all but 'required'
Details
| Submitted | 2004-07-16 21:53 UTC |
|---|---|
| From | derek at orangeconsulting dot ca |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 4.3.3 |
| OS | win2k |
| Roadmaps | (Not assigned) |
Comments
[2004-07-16 21:53 UTC] derek at orangeconsulting dot ca
Description:
------------
I'm using the latest version of quickform.
I'm having a problem with HTML_Quickform, and I think it might be a bug (or faulty docs).
Either way, the problem is with validation for anything beyond 'required'.
When I do this:
$form->addRule('Age', 'A numeric age is required', 'numeric', '', 'client');
No red * is placed beside the age input box, and the form is accepted no matter what.
If I change it to server-side validation (as follows) it still doesn't work.
$form->addRule('Age', 'A numeric age is required', 'numeric', '', '');
However, if I make the field 'required' instead of 'numeric', it works flawlessly for both server-side and client-side.
Any help would be much appreciated
PS--sorry for emailing Bertrand before noticing this bug reporter.
Reproduce code:
---------------
$form->addElement('text', 'Age', 'Age', 'size=3 maxlength=3');
$form->applyFilter('Age', 'trim');
$form->addRule('Age', 'A numeric age is required', 'numeric', '', 'client');
Expected result:
----------------
Server-side generated *error message or client-side alert notifying that the Age that was input must be numeric.
Actual result:
--------------
No red * is placed beside the age input box, no client-side alert pops-up, and the form is accepted regardless of the input.
The validation does not seem to work for 'numeric'.
[2004-07-22 17:16 UTC] jon at pixelmajik dot com
Note that in the default renderer the red * only shows up if a field is required and is the documented behaviour. Thus, a numeric rule would not complain if the user left the field empty, however it should complain if the user enters a non-numeric string.