From ddec41440984c9b205f62ed6af63317aa87e1e8f Mon Sep 17 00:00:00 2001 From: Isabelle Date: Fri, 9 Jan 2026 10:17:29 +0100 Subject: [PATCH] fix(falcon-PS9): Auto-format postcode This removes the annoying error when you type in 8011XD instead of 8011 XD --- falcon/_dev/js/theme/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/falcon/_dev/js/theme/index.js b/falcon/_dev/js/theme/index.js index fa9a71d..323fef8 100644 --- a/falcon/_dev/js/theme/index.js +++ b/falcon/_dev/js/theme/index.js @@ -79,4 +79,19 @@ $(() => { $(".js-select-link").on("change", ({ target }) => { window.location.href = $(target).val(); }); + + // Postcode input formatting + const $postCodeInput = $("input[name='postcode']"); + $postCodeInput.on("input", function () { + let value = $(this).val(); + + // Match 4 digits followed by 2 letters (e.g., 1234AB) + const match = value.match(/^(\d{4})([a-zA-Z]{2})$/); + + if (match) { + // Add space between numbers and letters + const formatted = `${match[1]} ${match[2]}`; + $(this).val(formatted); + } + }); });