X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=js%2Fkivi.Validator.js;fp=js%2Fkivi.Validator.js;h=4d03451b17bac68af6bbcf38cb3c29c397373c57;hp=b564ffb78940b94ac683f9bf51efd424228692f1;hb=b293ff8ad52fc76ba0c44783e3982418114d6b08;hpb=d4925a8b60f04674885e30d9316dc0263f8b9a84 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; } };