From c1f05dac17769164b09edf1c25f4619b5689892d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 25 Nov 2021 16:10:12 +0100 Subject: [PATCH] =?utf8?q?js-Validator:=20Leerzeichen=20trimmen=20k=C3=B6n?= =?utf8?q?nen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- js/kivi.Validator.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/js/kivi.Validator.js b/js/kivi.Validator.js index b564ffb78..4d03451b1 100644 --- a/js/kivi.Validator.js +++ b/js/kivi.Validator.js @@ -142,6 +142,26 @@ namespace("kivi.Validator", function(ns) { ns.annotate($e_annotate); return true; } + }, + trimmed_whitespaces: function($e, $e_annotate) { + $e_annotate = $e_annotate || $e; + + var string = $e.val(); + + if ($e.hasClass('tooltipstered')) + $e.tooltipster('destroy'); + + if (string.match(/^\s|\s$/)) { + $e.val(string.trim()); + + $e.tooltipster({ + content: kivi.t8("Leading and trailing whitespaces have been removed."), + contentAsHTML: true, + theme: 'tooltipster-light', + }); + $e.tooltipster('show'); + } + return true; } }; -- 2.20.1