From af1090553f65762a10838c7bde4939bfe57a79e3 Mon Sep 17 00:00:00 2001 From: kapcake Date: Tue, 18 Jun 2024 15:14:26 +0200 Subject: [PATCH] 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) {