Re: Quickform nonzero rule bug (?)
| From: | Bertrand Mansion | Date: | Wed, 25 Jun 2003 08:44:05 +0000 |
| Subject: | Re: Quickform nonzero rule bug (?) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17692@lists.php.net to get a copy of this message | ||
<jeroen@terena.nl> wrote :
> Hi,
>
> I've got a form using the nonzero rule and it doesn't work as expected.
>
> $form = new HTML_QuickForm;
>
> $form->addElement('text','list_size',null,array("size"=>3,"maxlength"=>2));
>
> $form->addElement('text','idle_time',null,array("size"=>3,"maxlength"=>2));
> $form->addElement('hidden','action','update');
>
> $form->addRule('list_size','This field is
> required','required');
> $form->addRule('list_size','Please choose a number between 1 and
> 99','nonzero');
> $form->addRule('idle_time','This field is
> required','required');
> $form->addRule('idle_time','Please choose a number between 1 and
> 99','nonzero');
>
> Anything below 10 won't validate. The rule on line 226 of Quickform.php is:
>
> 'nonzero' =>array('regex', '/^[1-9][0-9]+/'),
>
> Regex is not my strongest point, can anyone tell me of this looks right?
> It looks like it expect two digits..
Hi Jeroen,
You can probably use this regex instead: /^[1-9][0-9]?/
$form->addRule('list_size','Please choose a number between 1 and
99','regex', '/^[1-9][0-9]?/');
Bertrand