Make It Easy for Users to Enter Postal or ZIP Codes
Postal codes and ZIP codes vary wildly around the world. Don’t try to guess the format for the user: simply give them a text entry input field and allow them to enter their code. You can carry out validation if you need to on the server side.
Some of the better forms that I’ve seen in recent years include a “live lookup,” where entering a postal code (or part of a postal code) will return a list of possible addresses for the user to tap or click. Obviously, this reduces the keystrokes and clicks that the user needs to make to enter their address, and also reduces error rates by pre-filling fields with data that has already been sanitized. There are several free (and paid-for) services that offer this, including Google’s “Place Autocomplete.”
If you’re dealing with a web page (as opposed to a native app, for example), then using the autocomplete attribute on an input...