Home » HTML » HTML_QuickForm » Bug #2421
Problem with client-side validation
Details
| Submitted | 2004-09-30 14:05 UTC |
|---|---|
| From | pt2002 at mail dot pt |
| Assigned | ths |
| Status | Closed |
| Package | HTML_QuickForm |
| PHP Version | 5.0.1 |
| OS | Linux Fedora Core 2 |
| Roadmaps | (Not assigned) |
Comments
[2004-09-30 14:05 UTC] pt2002 at mail dot pt
Description:
------------
HTML_QuickForm 3.2.3
php 5.0.1, Mysql 4.1.5
Smarty 2.6.5
The problem is in client-side validation.
Reproduce code:
---------------
From the SmartyStatic_example.php file:
$form->addRule('email', 'Email address is required', 'required', '', 'client');
$form->addGroupRule('name', 'Name is required', 'required');
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', '8,10', 'client');
$form->addRule('country', 'Country is a required field', 'required', '', 'client');
Expected result:
----------------
I expect to see an alert box for every field with 'client' option if it fails to validate.
Actual result:
--------------
I see an alert if email or country are leaving empty but not for password. The form is shown but IE and Firefox show the error icon in the status bar.
The error is a sintax error in line 65:
if (value != '' && (value.length < 8 || value.length > ,) && !errFlag['pass']) {
It should be:
if (value != '' && (value.length < 8 || value.length > 10) && !errFlag['pass']) {
I changed line 58 in QuickForm/Rule/Range.php from
$test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')';
to:
$test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[2].')';
and it works fine for this example.
[2004-09-30 16:47 UTC] pt2002 at mail dot pt
Sure :)
In Range.php, $options is an array.
Thank you very much.
Regards