From 6b2308c17bd8add62e5cc7deb095ed28a2e2fcf4 Mon Sep 17 00:00:00 2001 From: Katrin Fischer Date: Fri, 14 Jul 2023 15:42:46 +0000 Subject: [PATCH] Bug 34169: Use jQuery validator plugin to validate amounts This is a first step towards more consistency and possibly supporting multiple input formats as well in the future. It allows us to mark all input fields for monetary values, such as prices, replacement prices, fees etc. with a class that is linked to a check for the 'number' format in the jQuery Validator plugin. This is the base patch that does nothing by itself, please see test plan in second patch. Signed-off-by: Michaela Sieber Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc | 1 + koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc index 0600f0a672..87dde3e610 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc @@ -11,6 +11,7 @@ number: _("Please enter a valid number."), digits: _("Please enter only digits."), equalTo: _("Please enter the same value again."), + number: _("Please add amount in valid format: 0.00"), maxlength: $.validator.format(_("Please enter no more than {0} characters.")), minlength: $.validator.format(_("Please enter at least {0} characters.")), rangelength: $.validator.format(_("Please enter a value between {0} and {1} characters long.")), diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js index 0e16baf053..abb3193bd7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js +++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js @@ -110,6 +110,9 @@ $(document).ready(function() { $(".validated").each(function() { $(this).validate(); }); + jQuery.validator.addClassRules("decimal", { + number: true + }); $("#logout").on("click",function(){ logOut(); -- 2.39.2