Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Postcode/ZIP validation wrong for a country: how to fix it

CNV-036Medium impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

Postcode validation is a check that a form runs on the postal code field before it lets you submit. It goes wrong when the rule does not match the country the visitor chose. Typical examples: a field that only accepts five digits rejects the UK postcode SW1A 1AA, the Canadian code K1A 0B1 and the Irish Eircode D02 X285.

The reverse also happens. A UK-only pattern blocks US ZIP codes, or a form demands a postcode in countries that do not use one, such as Ireland before Eircodes or many countries in Africa and the Middle East. Some countries also write codes in several ways: with or without a space, in upper or lower case, or with a ZIP+4 extension like 90210-1234.

Why it costs you leads or sales

The visitor has a real address and a real intent to buy or enquire, but the form tells them it is wrong. Most people do not try again with a fake code. They leave, or they stop trusting the checkout. The loss is silent: you see abandoned forms, not a rejected valid customer.

It hits hardest when you run ads or translated pages for several countries. The traffic you paid to reach a market is the traffic the form blocks. Small markets are easy to miss because the owner only ever tests with a home-country address.

Where a UK visitor drops out
  1. Ad click (UK)Visitor lands on the localised page
  2. Fills in formEnters name, email and SW1A 1AA
  3. Postcode checkRule expects 5 digits and rejects it
  4. SubmissionNever sent
  5. Lead or orderNever recorded

A form that only accepts 5-digit ZIP codes stops a valid UK customer at the address step.

Form completion by countryExample numbers
Form completion by country (example)US: 62 %; UK: 9 %; Canada: 11 %; Ireland: 10 %024486291110USUKCanadaIreland%

Example: completion rate for the same form when a US-only ZIP rule is applied to every country. Numbers are illustrative.

How to check if your site has it

Test the form with real postcodes from every country you sell to or advertise in. Pick the country in the dropdown first, because many forms change the rule when the country changes. If there is no country field, test with each format anyway.

Valid example postcodes to test with
CountryExampleFormat notes
United States90210 and 90210-12345 digits, optional 4-digit extension
United KingdomSW1A 1AA, M1 1AE, EC1A 1BBLetters and digits, 5 to 7 characters, space before the last 3
CanadaK1A 0B1Letter, digit, letter, space, digit, letter, digit
IrelandD02 X285Eircode: 3 characters, space, 4 characters
Netherlands1012 JS4 digits then 2 letters
Germany101155 digits
Hong Kong(none)No postcode; field must be optional
What to try
  • Enter each example above with the matching country selected
  • Type the UK code in lower case and without the space
  • Try a US ZIP+4 code
  • Leave the field empty for a country with no postcodes
  • Check the page source or network tab for a pattern attribute or a validation request
  • Test on mobile, where autofill can insert a different format

How to fix it

There are three sound options. Pick the simplest that fits your business. For many lead forms, a loose check or no check at all loses fewer customers than a strict one. For shipping, a strict check per country is useful, but only if it is right.

Fix postcode validation
  1. Find where the rule lives

    It may be a pattern attribute on the input, a JavaScript regex, a form builder setting, or a server-side check. Often it is more than one.

  2. Choose a strategy

    Either (a) pick the rule from the selected country, (b) use a loose rule such as 3 to 10 letters, digits, spaces or hyphens, or (c) remove the format check and keep the field required only where you ship.

  3. Make the field optional where no postcode exists

    Do not require a postcode for countries that do not use one. Make requirement depend on the country.

  4. Accept common variations

    Allow upper and lower case, an optional space, and ZIP+4. Clean the value (trim, uppercase) after validation rather than rejecting it.

  5. Update client and server together

    If only the browser rule changes, the server may still reject the entry. Change both so they agree.

  6. Retest every country

    Use the test table above and a real order or enquiry path.

Where to change it on your platform
  1. Form plugin

    In Gravity Forms, Contact Form 7, WPForms or similar, open the postcode field. Remove any custom regex or pattern, or switch the field to a plain text type. In Contact Form 7, check for a custom [text* postcode] with a validation filter in your theme.

  2. WooCommerce checkout

    WooCommerce validates postcodes per country by default. If checkout rejects a valid code, look for a plugin or snippet using the woocommerce_validate_postcode filter, and disable it to test.

Country-aware postcode check with a loose fallbackjavascript
const POSTCODE_RULES = {
  US: /^\d{5}(-\d{4})?$/,
  GB: /^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$/i,
  CA: /^[ABCEGHJ-NPRSTVXY]\d[ABCEGHJ-NPRSTV-Z] ?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
  IE: /^[A-Z]\d{2} ?[A-Z\d]{4}$/i,
  NL: /^\d{4} ?[A-Z]{2}$/i,
  DE: /^\d{5}$/
};
const NO_POSTCODE = ['HK', 'AE', 'QA'];
const LOOSE = /^[A-Za-z0-9][A-Za-z0-9 -]{1,8}[A-Za-z0-9]$/;

function isValidPostcode(value, country) {
  const v = value.trim();
  if (NO_POSTCODE.includes(country)) return true;
  if (v === '') return false;
  const rule = POSTCODE_RULES[country];
  return rule ? rule.test(v) : LOOSE.test(v);
}
Postcode field behaviour

Before

  • One pattern: exactly 5 digits
  • UK, Canadian and Irish codes rejected
  • Postcode required in every country
  • Server rule differs from the browser rule

After

  • Rule chosen by selected country, loose fallback
  • Local formats and spacing accepted
  • Optional where no postcode exists
  • Client and server share the same rule

How to confirm it's fixed

Confirm the fix
  1. Re-run the country test

    Submit the form once per country using the example postcodes, including lower case and no-space versions.

  2. Check the result, not only the form

    Confirm the entry reaches the inbox, CRM or order list with the postcode stored correctly.

  3. Test on mobile and with autofill

    Autofill may add a space or a different format than you typed.

How to prevent it happening again

Prevention habits
  • Keep a list of the countries you advertise in and a valid example postcode for each
  • Add that list to your release checklist whenever a form, theme or checkout plugin changes
  • Test every localised or geo variant page, not just the main one
  • Avoid hand-written regex copied from forum answers without testing it
  • Keep client and server rules in one place
  • Review form error complaints from support, and read form analytics by country

How FunnelGuard handles this

FunnelGuard does not check this yet. Country-specific postcode validation is a possible future check, so today you should not rely on it for this problem.

What FunnelGuard does do nearby: a robot visitor runs your real lead form or checkout journey on a schedule from the EU or the US, checks each step, and confirms the test lead reaches your inbox and CRM. If a change to a form breaks the whole journey for the robot's test data, you get one alert with a screenshot and a likely cause. That covers the test address it uses, not every country's postcode format.

To watch for this issue yourself, put a quarterly reminder in your calendar to submit each localised form with a real postcode from each market. You can also check form analytics or your CRM for a country with unusually few submissions, and ask support to flag any address-rejected complaints. You can try the free plan (1 site, 2 journeys, daily checks, no card) to monitor your main journey, and a free read-only website audit is also available.

Questions people ask

Why is my form rejecting a valid UK postcode?

The form most likely uses a US-style rule that only accepts five digits, or a UK pattern that does not allow the space or lower case. UK postcodes mix letters and digits, such as SW1A 1AA. Change the rule to be country-aware or loosen it, and update the server check as well.

How do I validate postcodes for different countries?

Read the selected country and apply a pattern for that country, with a loose fallback for countries you have not mapped. Keep the same rule on the browser and server. Trim spaces and normalise case after validating, rather than rejecting the input.

Should a postcode field be required on a lead form?

Only if you need it, for example to route leads by area or to ship goods. Some countries have no postcode system, so a required field blocks them. Make it optional or required depending on the country.

Why does my checkout say the ZIP code is invalid for Canada?

Canadian postal codes follow the pattern letter, digit, letter, space, digit, letter, digit, such as K1A 0B1. A form expecting digits only will reject them. Check the country selection, then look for a custom pattern or plugin overriding the checkout's default address rules.

Do all countries have postcodes?

No. Countries such as Hong Kong, Qatar and the United Arab Emirates do not use a general postcode, and some others only introduced them recently. A form that requires a postcode everywhere blocks real customers from those places.

Should I use a regex or an address lookup service for postcodes?

A simple regex per country is enough for most lead forms, with a loose fallback. An address lookup service can validate the full address, but it adds cost and another point of failure. Choose a lookup only if delivery accuracy matters.

Does FunnelGuard check postcode validation by country?

No. FunnelGuard does not check this yet, and it is a possible future check. It runs your real form journeys on a schedule and confirms test leads arrive, but it does not test each country's postcode format.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: intl_input_accepted on language / country variant runs (Stage 28): the country's real test postcode.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.