Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 28th, 2006, 05:07 PM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default validate zipcode based on country selection.

In my form I have a dropdownlist for Country field and one textbox for ZipCode.
I want the zipcode textbox to be validated only if U.S.A is selected from the Countrydropdown list.
Can you help


 
Old July 29th, 2006, 07:04 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

There are a few ways to validate zip codes, the best one is to use the United States Postal Services API (www.usps.com) however, unless you are using USPS to ship something, they will not allow you to use their API.

Another component that I have used is Assisted Solutions CityState Finder (http://www.assistedsolutions.com/com...tyStateFinder/) this works very well but it is very picky about City State Zip code combonations. (For example if suburb A shares the same zip code a Town A, the component will bark at you that the name of suburb A does not match the zip code provided and you need to supply Town As name.)

"The one language all programmers understand is profanity."
 
Old July 30th, 2006, 12:57 AM
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use custom validator for the zip code text box.
http://samples.gotdotnet.com/quickst...on.aspx#custom

 
Old July 30th, 2006, 01:48 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No, that wont work. The only thing a custom validator is going to do is verify that XXXXX are all numbers, which is fine, except that if i enter say 90210 and I say I am living in aspen, colorado while the custom validator would accept that value, it is not valid for the city and state i provided.

I think the OP is looking for a control that will validate the zip based on user entered city and state.

"The one language all programmers understand is profanity."
 
Old July 31st, 2006, 12:25 AM
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

"I want the zipcode textbox to be validated only if U.S.A is selected from the Countrydropdown list. "
-From the above statement, I understand that the input and a numeric input should only be asked in the zipcode box, if country is USA. Custom validator can validate this.

I agree, custom validator cannot validate, if the entered zipcode is the right one for the city, without a US zipcode database.

 
Old August 14th, 2006, 04:35 PM
Authorized User
 
Join Date: Apr 2006
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much for the information. I could make it work I wrote a javascript to validate the zipcode if it is for U.S.A.
Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
selection based on conditions rajesh_css XSLT 3 October 2nd, 2008 08:06 PM
Fill DataGrid based on the selection in combobox drani C# 12 October 11th, 2007 05:41 PM
Changing combobox based on selection iamme Visual Basic 2005 Basics 0 January 31st, 2007 09:04 PM
Query based on combo box selection help Elain Access 1 January 3rd, 2006 11:33 PM
Getting data based on field selection Trojan_uk Classic ASP Basics 1 December 9th, 2003 10:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.