kevkath
Posts: 4
|
| Posted: 04/02/2007, 8:50 AM |
|
I am trying to "Onvalidate" a textbox that contains a 5 digit zip code against another table that has a list of known zip codes. If the zip code that is not entered into the table I want the user to receive an error that they have entered a Invalid Zip Code. I have been unsuccessful so far. Can anyone offer some assistance?
After I get this resolved I am going to have it do the same lookup validation for phone area codes. I am using ASP and Microsoft Access for my database.
I am using a zip code database from http://www.zip-codes.com
Kevin
_________________
Kevin |
 |
 |
Wkempees
|
| Posted: 04/02/2007, 11:50 AM |
|
In theory, not ASP
do a CCDLookup() on the table holding the zipcodes.
Test for the result, any value is a hit, NULL will be a miss.
if your zipcode table has (id, zip) and is called ziptable
CCDLookup("id", "ziptable", "zip=" . textbox, $conn)
Of course you need the ASP equivalent of this pseudocode.
This whole thing you can stuff into a serverside validate.
Walter
|
|
|
 |
kevkath
Posts: 4
|
| Posted: 04/02/2007, 5:13 PM |
|
Thanks Walter for your input. I appreciate you help. Your comments helped me to get to where I needed to be. My final working code is as entered. I hope it will help others in the future.
Kevin
OnValidate:
IF NOT CCDLookup("ZipCode","zip_data","ZipCode=" & DBtrailerdata.ToSQL(orderform.Zip_Code.Value , ccsText), DBtrailerdata) <> "" THEN
orderform.Errors.addError("You Have Entered An Invalid Zip Code Address. Please Check And Re-Enter")
ELSE
END IF
_________________
Kevin |
 |
 |
|