Postcodes
Postcode Formats in Online Forms
Good postcode fields adapt to the country, accept spaces and hyphens, keep leading zeros and give clear errors. Practical form design advice.
Updated 14 October 2026 · 2 min read
A postcode field looks simple, yet it is one of the most common causes of checkout friction. A form that assumes one country's format will reject valid codes from others and lose customers.
Use a text field
Store and display postcodes as text, never as numbers. Letters, spaces and hyphens are valid in many countries, and a number field strips leading zeros. See leading zeros in postcodes.
Adapt to the country
Ask for the country first, then adjust the field:
- the label, such as "Postcode", "Postal code" or "ZIP code"
- the expected length and characters
- the placeholder that shows an example
- whether the field is required at all
Where a country has no nationwide system, make it optional; see countries without a postcode system.
Be forgiving with input
People type in many ways. Reasonable forms:
- trim leading and trailing spaces
- accept upper or lower case and normalise it
- accept a missing or extra space, or a hyphen where this is customary
- avoid forcing a particular separator on the user
More on this is in spaces and hyphens in postcodes.
Validate sensibly
Check that the format matches the selected country, but do not reject codes just because you have never seen them. Real postcodes appear after your reference data was built. The distinction between format and existence is covered in postcode validation: key concepts.
Give helpful errors
Say what is expected: "Enter a postcode like this example" is more useful than "Invalid input". Keep the entered value so the user can correct it instead of retyping.
Mobile and accessibility
Use the right keyboard type where the format is digits only, label the field properly for screen readers and avoid placeholders as the only label.
Beyond the code
Some stores add a map so that customers can mark the exact entrance. The UPCS WordPress, PrestaShop and OpenCart plugins show a map at checkout and attach a location to the order, in addition to the normal postcode field.
Frequently asked questions
Should a postcode field be a number input?
No. Use a text field, because many postcodes contain letters, spaces or hyphens, and numeric inputs can remove leading zeros.
Should the postcode be required for every country?
No. Some countries have no postcode system, so the field should be optional for them.
