From 68ed991d985bd4c9f0624458ad529119c355be03 Mon Sep 17 00:00:00 2001 From: KOWX712 Date: Thu, 13 Feb 2025 17:22:13 +0800 Subject: [PATCH] optimize input experience --- module/webui/scripts/security_patch.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/module/webui/scripts/security_patch.js b/module/webui/scripts/security_patch.js index 36b7204..00276a3 100644 --- a/module/webui/scripts/security_patch.js +++ b/module/webui/scripts/security_patch.js @@ -155,6 +155,14 @@ window.formatDate = function(input, type) { return formatted; } } else { + // Only allow numbers if not starting with 'n' + const numbersOnly = value.replace(/\D/g, ''); + if (numbersOnly !== value) { + input.value = numbersOnly; + value = numbersOnly; + formatted = numbersOnly.slice(0, 4); + } + // Add hyphens on 5th and 7th character if (value.length >= 4) { formatted += '-'+ value.slice(4, 6);