From 92c2e666606115f616f15829cb5304ed5b9b889f Mon Sep 17 00:00:00 2001 From: kapcake Date: Tue, 18 Jun 2024 15:02:20 +0200 Subject: [PATCH 1/2] Update money regex to allow more than 6 figures on integer part --- wwwroot/js/shared.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js index 5eda87b..15ff202 100644 --- a/wwwroot/js/shared.js +++ b/wwwroot/js/shared.js @@ -178,8 +178,8 @@ function uploadFileAsync(event) { }); } function isValidMoney(input) { - const euRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}(\.?\d{3})?(,\d{1,3}?)?\)?$/; - const usRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}(,?\d{3})?(\.\d{1,3}?)?\)?$/; + const euRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}((\.\d{3})*|(\d{3})*)(,\d{1,3}?)?\)?$/; + const usRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}((,\d{3})*|(\d{3})*)(\.\d{1,3}?)?\)?$/; return (euRegex.test(input) || usRegex.test(input)); } function initDatePicker(input, futureOnly) { @@ -1053,4 +1053,4 @@ function bindModalInputChanges(modalName) { $(`#${modalName} select, #${modalName} input[type='checkbox']`).off('input').on('input', function (e) { $(e.currentTarget).attr('data-changed', true); }); -} \ No newline at end of file +} From af1090553f65762a10838c7bde4939bfe57a79e3 Mon Sep 17 00:00:00 2001 From: kapcake Date: Tue, 18 Jun 2024 15:14:26 +0200 Subject: [PATCH 2/2] Update money regex to not allow unlimited figures The regex now allows up to 8 groups of 3 digits on the integer part, which is within the bounds of C# decimal, preventing the user to go out of bounds on the form input. --- wwwroot/js/shared.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wwwroot/js/shared.js b/wwwroot/js/shared.js index 15ff202..af264d6 100644 --- a/wwwroot/js/shared.js +++ b/wwwroot/js/shared.js @@ -178,8 +178,8 @@ function uploadFileAsync(event) { }); } function isValidMoney(input) { - const euRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}((\.\d{3})*|(\d{3})*)(,\d{1,3}?)?\)?$/; - const usRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}((,\d{3})*|(\d{3})*)(\.\d{1,3}?)?\)?$/; + const euRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}((\.\d{3}){0,8}|(\d{3}){0,8})(,\d{1,3}?)?\)?$/; + const usRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\d{1,3}((,\d{3}){0,8}|(\d{3}){0,8})(\.\d{1,3}?)?\)?$/; return (euRegex.test(input) || usRegex.test(input)); } function initDatePicker(input, futureOnly) {