Solved

single textfield address entry

Posted on 2008-10-06
3
328 Views
Last Modified: 2013-12-17
Hi guys,
I'm trying to find a technique of providing single textbox address entry - like google / MS maps.

ie: "1205 redshire, Dallas, OH"

More specifically, how to enforce the rules client side and a process to parse the string into parameters that I can use to supply to a service.
The more detailed the better.
Using ASP.NET/C#.
Regards.
0
Comment
Question by:rotovibe
3 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 500 total points
ID: 22657039
To answer your question in the most straightforward manner possible, you would want to use a regular expression validator to validate the street address. Once validated, you could use String.Split(',') to split it along the commas which would give you the parameters.

That said, you really don't want to do this. It is much, much easier and time effective to have separate fields on your form for street, City, State, and Zip. The reason you don't see single line street address is that they are terribly difficult to validate. For example, here is a regex you can use:
http://www.sitepoint.com/forums/showthread.php?t=476591

You'll notice its a bit complex, and extremly long, and the comments show that it doesnt handle all cases. If you are satisfied with some cases and rejecting others then I suppose this would work for you.
If you are familiar with regex then you can modify it to cover more cases as you come across them, but if you are not familiar with regex then that is a semester course in itself for complex expressions.

I dont want to burst your bubble, if you like a challenge, and are willing to spend several hours perfecting a regex then go for it. The problems with street addresses are, to name a few:
-What about P.O. Boxes?
-What about street types: Street, Drive, Court, Circle, Boulevard, Parkway, Road, Way, Place, Avenue ...
-What if they abbreviate the above to: St, Dr, Ct,, Cir, Blvd, Pkwy or Pwy, Rd, Wy, Pl, Ave or Av
-BTW, this is best handled by parsing the string before validation, and converting all known street types to either an abbreviation or the full name. That part is not so hard. :)
-What if it doesnt include a street address? Very large companies, and in a few cases very small towns will do this: one you may have see is the IRS (though that probably isnt applicable to your app, you get my point) IRS, Fresno, CA XXXXX. or May Smith, Tinytown, IA, XXXXX
-Apt numbers, suite numbers
-An extra line in the address. John Smith, Accounting Dep, Big Company, 124 Madison Ave, New York, NY 20222

-But that is how it is done, there is a regex to get you started. How does google do it? They have an army of engineers and a big qa dept to test lots of combinations.
Good luck!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now