473,224 Members | 1,595 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

ValidationExpression for zip/postal codes

I'm trying to get my zip code textbox to validate both US zip codes and Canadian Postal code formats. But I can't figure out the syntax. Can somebody help? Here is what I got:

Expand|Select|Wrap|Line Numbers
  1. <asp:regularexpressionvalidator id="rxZipCode" runat="server" ControlToValidate="txtZipCode" Display="Dynamic" ErrorMessage="Zip Code is invalid." ValidationExpression="\d{5}?" & "[A-Z]\\d[A-Z] \\d[A-Z]\\d">*</asp:regularexpressionvalidator>
Oct 5 '07 #1
5 3933
7,872 Expert 4TB
Good luck!
Postal codes are a mess
us can be just 5 or just 5 plus another 4 or just 5 plus 5, or more.
Some contain letters as well as numbers.
Oct 5 '07 #2
So ValidationExpression doesn't have an "or' operator?
Oct 5 '07 #3
7,872 Expert 4TB
So ValidationExpression doesn't have an "or' operator?
It should, I would just be surprised if you can find a big enough regex to cover postal codes.
Oct 5 '07 #4
Am I close with this? I put the | operator in there. It still only accepts US zips.

ValidationExpression="\d{5}?|[A-Z]\\d[A-Z] \\d[A-Z]\\d

The regex for Canadian Postals should be ok right? Is just ANA NAN, right?
Oct 5 '07 #5
Shashi Sadasivan
1,435 Expert 1GB
This and This too

They give some regex's

Oct 5 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Andrew McLean | last post by:
I have a problem that is suspect isn't unusual and I'm looking to see if there is any code available to help. I've Googled without success. Basically, I have two databases containing lists of...
by: Dave \IT\ | last post by:
I'm looking to find out how I'd go about setting up a database where a visitor to my site could punch in their postal code, and find out how far they are from another postal code. For example,...
by: Axel Foley | last post by:
I used some of the excellent resources from DITHERING.COM for help in my groveling newbie attempts to cough up working form validation.... I cut and pasted bits of code to check USA ZIP codes and...
by: Bobbie | last post by:
I am trying to make mailing labels. The zip/postal codes are 9 digits (ex: 40601-0223) I ran a query and put in the input mask 00000/-9999;;_ and it works but when I make the mailing labels and...
by: Ronnie | last post by:
Hello there, I am creating a contact database and I would like my user to enter postal code (Canadian) and the city/province will be automatically filled in. I am sure this can be done and I can...
by: Andy Eshtry | last post by:
I have a radio button list, a textbox representing SIN or EIN based on my radio button list selection so I put 2 regularexpressionvalidator to evaluate the value of textbox. EIN must be (for...
by: Surfdog | last post by:
Hello all, I'm unable to figure out how to process the zip codes with regexes. We have a custom component that takes a find pattern, a replace pattern, and the input value, and will output the...
by: skardian | last post by:
I am currently using the ChangePassword control for ASP.NET 2.0 to allow users to update or change their password as need be. However I am running into a problem with the Regular Expression...
by: racshah | last post by:
Hi I have been asked to validate postal/zip codes against the countries like Netherland, United Kingdom, Spain, Italy, Belgium etc. Can anyone suggest that how can I do it programmatically using...
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.