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.
This commit is contained in:
kapcake
2024-06-18 15:14:26 +02:00
committed by GitHub
parent 92c2e66660
commit af1090553f

View File

@@ -178,8 +178,8 @@ function uploadFileAsync(event) {
}); });
} }
function isValidMoney(input) { function isValidMoney(input) {
const euRegex = /^\$?(?=\(.*\)|[^()]*$)\(?\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})*|(\d{3})*)(\.\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)); return (euRegex.test(input) || usRegex.test(input));
} }
function initDatePicker(input, futureOnly) { function initDatePicker(input, futureOnly) {