|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
quickform - regex
hi,
It weird. The regex function does not seem to work at all when I create rules. Does anybody have it working? $form->addElement('text', 'time_spent', '<b>Time Spent On Activity</b><br><font class="mainsmall">hh:mm', 'size="10", maxlength="5"'); $form->addrule('time_spent', 'Please enter a valid Time Spent on your Activity', 'required', 'regex', '/^[0-9]{2}:[0-9]{2}$/', null, 'server'); |
|
#2
|
|||
|
|||
|
RE: quickform - regex
Sorry not quite understand your problem but just found some related info here.
http://pear.php.net/bugs/bug.php?id=1810 Maybe it helps? I not sure it that is your problem? |
|
#3
|
|||
|
|||
|
RE: quickform - regex
sorry for not being clear,
What I meant was that the regex rule is not applied at all. I am able to enter any value for the 'time_spent' form element. The regex rule should not validate the form if the format of the data enetered is not ^[0-9]{2}:[0-9]{2}$ . At the minute the rule only checks if the form element is not blank. |
|
#4
|
|||
|
|||
|
RE: quickform - regex
I fixed it.
I don't know if it's optimized bt it's the best way I found. It looks like the regex rule does not like the 'required' keyword. To make the field required, I added a minlength rule. $form->addElement('text', 'time_spent', '<b>Time Spent On Activity</b><br><font class="mainsmall">hh:mm', 'size="10", maxlength="5"'); $form->addrule('time_spent', 'Please enter a valid Time Spent on your Activity', 'required', 'minlength', '1', null, 'server'); $form->addrule('time_spent', 'Please enter a valid Time Spent on your Activity', 'regex', '/^[0-9]{2}:[0-9]{2}$/', null, 'server'); |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > quickform - regex |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|