^\d{5}(-\d{4})?$
Your original one allowed a space too . If you want that it is
^\d{5}([- ]\d{4})?$
If you are not on cfmx, replace \d by [0-9]
> -----Original Message-----
> From: Che Vilnonis [mailto:[EMAIL PROTECTED]
> Sent: woensdag 23 juni 2004 17:17
> To: CF-Talk
> Subject: Quick Regular _expression_ Question.
>
> Hello all. I use the following to regular _expression_ to
> validate zipcodes.
>
> <cfif NOT REFind('^[[:digit:]]{5}(( |-)?[[:digit:]]{4})?$',
> #FORM.BillZip#)>
> <cfset CreateAccountFlag = "Yes">
> <cfset BillZipInvalidFlag = "Yes">
> </cfif>
>
> When a customer inputs a 9 digit zip code WITHOUT the hyphen,
> no error is set. (i.e. 902101444) How would I modify this to
> incorporate a mandatory hyphen when a 9 digit zip code is
> inputed and still work for all other zip codes?
>
> TIA...Che
>
>
>
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
- Quick Regular Expression Question. Che Vilnonis
- Re: Quick Regular Expression Question. Ben Doom
- Re: Quick Regular Expression Question. Jerry Johnson
- RE: Quick Regular Expression Question. Che Vilnonis
- Re: Quick Regular Expression Question. Marlon Moyer
- Pascal Peters