Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

single textfield address entry

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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 video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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