Solved

single textfield address entry

Posted on 2008-10-06
3
326 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

13 Experts available now in Live!

Get 1:1 Help Now