Don't validate your address forms!

By uliwitness

One of the things that I often have problems with, especially on new web sites from US-based companies, is how they treat addresses and phone numbers. So, here’s a few rules that should help you make sure international users/clients can use your address form.

The ground rule is, you shouldn’t validate the form in any way, because e.g. in Germany addresses are pretty freeform. E.g. most US forms expect a zip code and postal code. While the former doesn’t exist in Germany (they’re kinda “built in” to the postal code there), the latter goes before the city. Also, keep in mind that assuming the order of the first and last names may not work for some countries (though that’s mostly outside Europe, so I won’t try giving any examples for fear of exposing my cluelessness). Similarly, in Germany the street number goes after the street.

Deutsche Post uses machines to pre-sort mail over here, even for hand-written addresses, and that means if they’re wrongly formatted, they will first get delivered to a wrong place, and only then a human will see they’re wrong and re-deliver them to the right place.

E.g., valid addresses in Germany could be:

Firstname Lastname
Streetname 123a/1
Suburb
12345 City

 

Or it may be

Company
12345 City

 

Or it may be

Firstname Lastname
Areaname
12345 City

 

Or it may be

Firstname Lastname
bei PersonTheyreStayingWithName
Street-name-or-so 12
Appartment 7
12345 City

 

Or you may have Mannheim, where the streets are divided into blocks and you have

Firstname Lastname
P4,7
68123 Mannheim

 

And I haven’t even accounted for PO boxes here, though they’re about the same as the “Area” address above.

So, you can neither assume that the actual address has the form “Number Street”, nor “Street Number”, nor that the building number is just a number (there are dashes, slashes, capital and lowercase letters, apartment numbers etc.).

Also be careful with length limits, because I know people who lived in streets called “Straße des 15. Juli 123″ or “Großherzog-Friedrich-Straße 1234″. Both of which had problems with many paper forms and some web forms (but in paper forms you can just write narrower or on the edge). Oh, and Berlin used to hold the record with a street named “Prinz-August-Wilhelm-von-Württemberg-Straße” (a whopping 43 characters long, though recently renamed)

Though in general, most German addresses can be made to fit into the following scheme:

Name:
Address:
Address 2:
Postal code (5 digits, but may start with zero):
City:

if you want to support other countries besides Germany, you should probably use one field for postal code and city, and not validate that in any way, because the UK have alphanumeric postal codes, while Switzerland has only four digits…

My best recommendation is to get beta testers from as many countries as you can and have them supply you with example addresses, especially particularly long and short ones, as well as odd ones. That way you can test your form. Where that isn’t possible, think about adding a (maybe optional) freeform address field where people can enter addresses that don’t fit your proposed scheme.

And did I mention that you better not try to restrict or format international phone numbers? In particular, be sure to allow for “+”, “-” and brackets so they can include the international prefix, and don’t auto-group numbers because e.g. German area codes can be four or five digits in length, and lose their leading zero when called internationally… So, a valid number would be something like:

+49 (0)1234 12345678-123

but can also be

+49 (0)12 1234

 

The dash above can be ignored, but it’s still bound to make the typical US phone number field choke.

 

If you know foreign addresses that don’t fit the above two-address-field scheme, please leave a comment with an (anonymized!) example. I’d be interested in working out a scheme for addresses here that people can just apply to their forms to have it work internationally.

Share your thoughts