PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 29th, 2009, 01:59 PM
majorsdd majorsdd is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Location: Dayton, OH
Posts: 2 majorsdd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 43 sec
Reputation Power: 0
Facebook
[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

Reply With Quote
  #2  
Old June 29th, 2009, 03:49 PM
wiesemann wiesemann is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 172 wiesemann User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 2 m
Reputation Power: 3
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.

Reply With Quote
  #3  
Old June 29th, 2009, 04:52 PM
majorsdd majorsdd is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Location: Dayton, OH
Posts: 2 majorsdd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 43 sec
Reputation Power: 0
Facebook
[SOLVED] Quickform regex rule problem

Quote:
Originally Posted by wiesemann
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.


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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > Quickform regex rule problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
Stay green...Green IT