From 83bc5ef2e31fc49d24e79e4b33cee74a596d9ea1 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 14 Jun 2018 18:18:48 -0400 Subject: [PATCH] fixes #669 fix paste error overflowing mask length --- jquery.datetimepicker.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jquery.datetimepicker.js b/jquery.datetimepicker.js index 7c7a6df..60956b6 100644 --- a/jquery.datetimepicker.js +++ b/jquery.datetimepicker.js @@ -2370,7 +2370,7 @@ var datetimepickerFactory = function ($) { setCaretPos(input[0], 0); } - input.on('paste.xdsoft', function (event) { + input.off('paste.xdsoft').on('paste.xdsoft', function (event) { // couple options here // 1. return false - tell them they can't paste // 2. insert over current characters - minimal validation @@ -2388,7 +2388,8 @@ var datetimepickerFactory = function ($) { var valueBeforeCursor = val.substr(0, pos); var valueAfterPaste = val.substr(pos + pastedData.length); - val = valueBeforeCursor + pastedData + valueAfterPaste; + val = valueBeforeCursor + pastedData + valueAfterPaste; + val = val.substring(0, options.mask.length) pos += pastedData.length; if (isValidValue(options.mask, val)) {