|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
[SOLVED] Quickform regex rule problem
Greetings,
I'm trying to set up a validation rule in a Quickform to validate either a US ZIP code *or* a Canadian postal code. Here;s what I have: Code:
$form->addElement( 'text' , 'txtZIP', 'ZIP/postal code:');
$form->addRule( 'txtZIP', 'Please provide your ZIP/postal code', 'required' );
$form->addRule( 'txtZIP', 'Please provide a valid ZIP/postal code', 'regex',
'(^\d{5}(-\d{4})?$)|(^[ABCEGHJKLMNPRSTVXYabceghjklmnprstvxy]{1}\d{1}[A-Za-z]{1} *\d{1}[A-Za-z]{1}[1-9A-Za-z]{1}$)' );
What I receive is: Warning: preg_match() [function.preg-match]: Unknown modifier '|' in /usr/share/pear/HTML/QuickForm/Rule/Regex.php on line 73 If I use the regex for just the US ZIP code or the Canadian postal code, it works fine. Any ideas? Last edited by majorsdd : June 29th, 2009 at 04:55 PM. Reason: problem solved - changed subject |
|
#2
|
|||
|
|||
|
I'd say that even a single ZIP code can't work because the expression is missing the delimiter charachter (e.g. '/') at the beginning and at the end.
|
|
#3
|
|||
|
|||
|
[SOLVED] Quickform regex rule problem
Quote:
That's a good point. That was simple laziness on my part. Each of the two parts worked fine without the delimiters but together (with the or(|)) they didn't. In fact, in the short time I've been using this package, this is the first time I've actually had to use the delimiters. Thanks for the help. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > Quickform regex rule problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|