use-mask-input 1.0.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/example/App.example.d.ts +3 -0
  2. package/dist/{useMaskInput.test.d.ts → example/index.d.ts} +0 -0
  3. package/dist/index.js +1 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.modern.js +1 -2
  6. package/dist/index.modern.js.map +1 -1
  7. package/dist/useMaskInput.d.ts +3 -3
  8. package/node_modules/inputmask/README.md +94 -61
  9. package/node_modules/inputmask/dist/inputmask.es6.js +5 -0
  10. package/node_modules/inputmask/dist/inputmask.js +2900 -2868
  11. package/node_modules/inputmask/dist/inputmask.min.js +3 -3
  12. package/node_modules/inputmask/dist/jquery.inputmask.js +2840 -2807
  13. package/node_modules/inputmask/dist/jquery.inputmask.min.js +3 -3
  14. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +5 -0
  15. package/node_modules/inputmask/lib/canUseDOM.js +7 -0
  16. package/node_modules/inputmask/lib/defaults.js +36 -2
  17. package/node_modules/inputmask/lib/definitions.js +1 -1
  18. package/node_modules/inputmask/lib/dependencyLibs/events.js +19 -9
  19. package/node_modules/inputmask/lib/environment.js +2 -0
  20. package/node_modules/inputmask/lib/eventhandlers.js +55 -44
  21. package/node_modules/inputmask/lib/eventruler.js +10 -9
  22. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +543 -430
  23. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +117 -99
  24. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +590 -574
  25. package/node_modules/inputmask/lib/global/window.js +2 -1
  26. package/node_modules/inputmask/lib/inputHandling.js +30 -18
  27. package/node_modules/inputmask/lib/inputmask.js +9 -2
  28. package/node_modules/inputmask/lib/inputmaskElement.js +2 -1
  29. package/node_modules/inputmask/lib/keycode.json +4 -0
  30. package/node_modules/inputmask/lib/mask-lexer.js +434 -436
  31. package/node_modules/inputmask/lib/mask.js +4 -4
  32. package/node_modules/inputmask/lib/masktoken.js +13 -0
  33. package/node_modules/inputmask/lib/polyfills/Array.includes.js +48 -0
  34. package/node_modules/inputmask/lib/{getPrototypeOf.js → polyfills/Object.getPrototypeOf.js} +0 -0
  35. package/node_modules/inputmask/lib/positioning.js +5 -5
  36. package/node_modules/inputmask/lib/validation-tests.js +108 -46
  37. package/node_modules/inputmask/lib/validation.js +82 -73
  38. package/node_modules/inputmask/package.json +41 -69
  39. package/package.json +40 -38
  40. package/node_modules/inputmask/CHANGELOG.md +0 -744
  41. package/node_modules/inputmask/index.js +0 -1
  42. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jqlite.js +0 -20
@@ -0,0 +1,5 @@
1
+ import "./inputmask.js";
2
+
3
+ const inputmask = window.Inputmask;
4
+ window.Inputmask = undefined;
5
+ export default inputmask;
@@ -0,0 +1,7 @@
1
+ const canUseDOM = !!(
2
+ typeof window !== "undefined" &&
3
+ window.document &&
4
+ window.document.createElement
5
+ );
6
+
7
+ export default canUseDOM;
@@ -1,3 +1,5 @@
1
+ import keyCode from "./keycode.json";
2
+
1
3
  export default {
2
4
  _maxTestPos: 500,
3
5
  placeholder: "_",
@@ -49,7 +51,37 @@ export default {
49
51
  tabThrough: false, //allows for tabbing through the different parts of the masked field
50
52
  supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
51
53
  //specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
52
- ignorables: [8, 9, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 0, 229],
54
+ ignorables: [
55
+ keyCode.BACKSPACE,
56
+ keyCode.TAB,
57
+ keyCode["PAUSE/BREAK"],
58
+ keyCode.ESCAPE,
59
+ keyCode.PAGE_UP,
60
+ keyCode.PAGE_DOWN,
61
+ keyCode.END,
62
+ keyCode.HOME,
63
+ keyCode.LEFT,
64
+ keyCode.UP,
65
+ keyCode.RIGHT,
66
+ keyCode.DOWN,
67
+ keyCode.INSERT,
68
+ keyCode.DELETE,
69
+ 93,
70
+ 112,
71
+ 113,
72
+ 114,
73
+ 115,
74
+ 116,
75
+ 117,
76
+ 118,
77
+ 119,
78
+ 120,
79
+ 121,
80
+ 122,
81
+ 123,
82
+ 0,
83
+ 229
84
+ ],
53
85
  isComplete: null, //override for isComplete - args => buffer, opts - return true || false
54
86
  preValidation: null, //hook to preValidate the input. Usefull for validating regardless the definition. args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
55
87
  postValidation: null, //hook to postValidate the result from isValid. Usefull for validating the entry as a whole. args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval => return true/false/json
@@ -63,5 +95,7 @@ export default {
63
95
  inputmode: "text", //specify the inputmode
64
96
  importDataAttributes: true, //import data-inputmask attributes
65
97
  shiftPositions: true, //shift position of the mask entries on entry and deletion.
66
- usePrototypeDefinitions: true //use the default defined definitions from the prototype
98
+ usePrototypeDefinitions: true, //use the default defined definitions from the prototype
99
+ validationEventTimeOut: 3000, //Time to show validation error on form submit
100
+ substitutes: {} //define character substitutes
67
101
  };
@@ -10,4 +10,4 @@ export default {
10
10
  "*": {
11
11
  validator: "[0-9\uFF10-\uFF19A-Za-z\u0410-\u044F\u0401\u0451\u00C0-\u00FF\u00B5]"
12
12
  }
13
- }
13
+ };
@@ -1,6 +1,7 @@
1
1
  import extend from "./extend";
2
2
  import window from "../global/window";
3
3
  import DependencyLib from "./inputmask.dependencyLib";
4
+ import canUseDOM from "../canUseDOM";
4
5
 
5
6
  export {on, off, trigger, Event};
6
7
 
@@ -12,13 +13,15 @@ let Event;
12
13
  if (typeof window.CustomEvent === "function") {
13
14
  Event = window.CustomEvent;
14
15
  } else {
15
- Event = function (event, params) {
16
- params = params || {bubbles: false, cancelable: false, detail: undefined};
17
- var evt = document.createEvent("CustomEvent");
18
- evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
19
- return evt;
20
- };
21
- Event.prototype = window.Event.prototype;
16
+ if (canUseDOM) {
17
+ Event = function (event, params) {
18
+ params = params || {bubbles: false, cancelable: false, detail: undefined};
19
+ var evt = document.createEvent("CustomEvent");
20
+ evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
21
+ return evt;
22
+ };
23
+ Event.prototype = window.Event.prototype;
24
+ }
22
25
  }
23
26
 
24
27
 
@@ -118,7 +121,7 @@ function off(events, handler) {
118
121
  return evts;
119
122
  }
120
123
 
121
- if (isValidElement(this[0])) {
124
+ if (isValidElement(this[0]) && events) {
122
125
  eventRegistry = this[0].eventRegistry;
123
126
  elem = this[0];
124
127
 
@@ -154,7 +157,14 @@ function trigger(events /* , args... */) {
154
157
  // The custom event that will be created
155
158
  if (document.createEvent) {
156
159
  try {
157
- evnt = new CustomEvent(ev, params);
160
+ switch (ev) {
161
+ case "input":
162
+ params.inputType = "insertText";
163
+ evnt = new InputEvent(ev, params);
164
+ break;
165
+ default:
166
+ evnt = new CustomEvent(ev, params);
167
+ }
158
168
  } catch (e) {
159
169
  evnt = document.createEvent("CustomEvent");
160
170
  evnt.initCustomEvent(ev, params.bubbles, params.cancelable, params.detail);
@@ -1,3 +1,5 @@
1
+ import window from "./global/window";
2
+
1
3
  const ua = (window.navigator && window.navigator.userAgent) || "",
2
4
  ie = (ua.indexOf("MSIE ") > 0) || (ua.indexOf("Trident/") > 0),
3
5
  mobile = "ontouchstart" in window, //not entirely correct but will currently do
@@ -8,12 +8,12 @@ import {
8
8
  translatePosition
9
9
  } from "./positioning";
10
10
  import keyCode from "./keycode.json";
11
- import {iemobile, iphone} from "./environment";
12
- import {handleRemove, isComplete, isValid} from "./validation";
13
- import {applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer} from "./inputHandling";
14
- import {getPlaceholder, getTest} from "./validation-tests";
11
+ import { iemobile, iphone } from "./environment";
12
+ import { handleRemove, isComplete, isSelection, isValid } from "./validation";
13
+ import { applyInputValue, checkVal, clearOptionalTail, HandleNativePlaceholder, writeBuffer } from "./inputHandling";
14
+ import { getPlaceholder, getTest } from "./validation-tests";
15
15
 
16
- export {EventHandlers};
16
+ export { EventHandlers };
17
17
 
18
18
  var EventHandlers = {
19
19
  keydownEvent: function (e) {
@@ -40,12 +40,14 @@ var EventHandlers = {
40
40
  } else if ((k === keyCode.HOME && !e.shiftKey) || k === keyCode.PAGE_UP) { //Home or page_up
41
41
  e.preventDefault();
42
42
  caret.call(inputmask, input, 0, e.shiftKey ? pos.begin : 0, true);
43
- } else if (((opts.undoOnEscape && k === keyCode.ESCAPE) || (k === 90 && e.ctrlKey)) && e.altKey !== true) { //escape && undo && #762
43
+ } else if (((opts.undoOnEscape && k === keyCode.ESCAPE) || (false && k === keyCode.Z && e.ctrlKey)) && e.altKey !== true) { //escape && undo && #762
44
44
  checkVal(input, true, false, inputmask.undoValue.split(""));
45
45
  $input.trigger("click");
46
- // } else if (k === keyCode.INSERT && !(e.shiftKey || e.ctrlKey) && inputmask.userOptions.insertMode === undefined) { //insert
47
- // opts.insertMode = !opts.insertMode;
48
- // caret(input, pos.begin, pos.end);
46
+ } else if (k === keyCode.INSERT && !(e.shiftKey || e.ctrlKey) && inputmask.userOptions.insertMode === undefined) { //insert
47
+ if (!isSelection.call(inputmask, pos)) {
48
+ opts.insertMode = !opts.insertMode;
49
+ caret.call(inputmask, input, pos.begin, pos.begin);
50
+ } else opts.insertMode = !opts.insertMode;
49
51
  } else if (opts.tabThrough === true && k === keyCode.TAB) {
50
52
  if (e.shiftKey === true) {
51
53
  pos.end = seekPrevious.call(inputmask, pos.end, true);
@@ -97,11 +99,11 @@ var EventHandlers = {
97
99
 
98
100
  var input = inputmask.el,
99
101
  $input = $(input),
100
- k = e.which || e.charCode || e.keyCode;
102
+ k = e.keyCode;
101
103
 
102
104
  if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || inputmask.ignorable))) {
103
- if (k === keyCode.ENTER && inputmask.undoValue !== getBuffer.call(inputmask).join("")) {
104
- inputmask.undoValue = getBuffer.call(inputmask).join("");
105
+ if (k === keyCode.ENTER && inputmask.undoValue !== inputmask._valueGet(true)) {
106
+ inputmask.undoValue = inputmask._valueGet(true);
105
107
  // e.preventDefault();
106
108
  setTimeout(function () {
107
109
  $input.trigger("change");
@@ -113,11 +115,13 @@ var EventHandlers = {
113
115
  //special treat the decimal separator
114
116
  if ((k === 44 || k === 46) && e.location === 3 && opts.radixPoint !== "") k = opts.radixPoint.charCodeAt(0);
115
117
  var pos = checkval ? {
116
- begin: ndx,
117
- end: ndx
118
- } : caret.call(inputmask, input),
118
+ begin: ndx,
119
+ end: ndx
120
+ } : caret.call(inputmask, input),
119
121
  forwardPosition, c = String.fromCharCode(k);
120
122
 
123
+ //allow for character substitution
124
+ c = opts.substitutes[c] || c;
121
125
  maskset.writeOutBuffer = true;
122
126
  var valResult = isValid.call(inputmask, pos, c, strict, undefined, undefined, undefined, checkval);
123
127
  if (valResult !== false) {
@@ -163,8 +167,8 @@ var EventHandlers = {
163
167
 
164
168
  if (inputmask.isRTL) {
165
169
  tempValue = caretPos.end;
166
- caretPos.end = caretPos.begin;
167
- caretPos.begin = tempValue;
170
+ caretPos.end = translatePosition.call(inputmask, caretPos.begin);
171
+ caretPos.begin = translatePosition.call(inputmask, tempValue);
168
172
  }
169
173
 
170
174
  var valueBeforeCaret = inputValue.substr(0, caretPos.begin),
@@ -182,19 +186,25 @@ var EventHandlers = {
182
186
  } //allow native paste event as fallback ~ masking will continue by inputfallback
183
187
 
184
188
  var pasteValue = inputValue;
189
+ if (inputmask.isRTL) {
190
+ pasteValue = pasteValue.split("")
191
+ for (let c of getBufferTemplate.call(inputmask)) {
192
+ if (pasteValue[0] === c)
193
+ pasteValue.shift();
194
+ }
195
+ pasteValue = pasteValue.join("");
196
+ }
185
197
  if (typeof opts.onBeforePaste === "function") {
186
- pasteValue = opts.onBeforePaste.call(inputmask, inputValue, opts);
198
+ pasteValue = opts.onBeforePaste.call(inputmask, pasteValue, opts);
187
199
  if (pasteValue === false) {
188
- return e.preventDefault();
200
+ return false;
189
201
  }
190
202
  if (!pasteValue) {
191
203
  pasteValue = inputValue;
192
204
  }
193
205
  }
194
206
  checkVal(input, true, false, pasteValue.toString().split(""), e);
195
- // writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, inputmask.undoValue !== getBuffer().join(""));
196
-
197
- return e.preventDefault();
207
+ e.preventDefault()
198
208
  },
199
209
  inputFallBackEvent: function (e) { //fallback when keypress is not triggered
200
210
  const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
@@ -299,13 +309,12 @@ var EventHandlers = {
299
309
  caretPos = caret.call(inputmask, input, undefined, undefined, true);
300
310
 
301
311
  if (buffer !== inputValue) {
302
- // inputValue = radixPointHandler(input, inputValue, caretPos);
303
312
  inputValue = ieMobileHandler(input, inputValue, caretPos);
304
313
 
305
314
  var changes = analyseChanges(inputValue, buffer, caretPos);
306
315
 
307
316
  // console.log(JSON.stringify(changes));
308
- if ((input.inputmask.shadowRoot || document).activeElement !== input) {
317
+ if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
309
318
  input.focus();
310
319
  }
311
320
  writeBuffer(input, getBuffer.call(inputmask));
@@ -315,7 +324,7 @@ var EventHandlers = {
315
324
  case "insertReplacementText":
316
325
  changes.data.forEach(function (entry, ndx) {
317
326
  var keypress = new $.Event("keypress");
318
- keypress.which = entry.charCodeAt(0);
327
+ keypress.keyCode = entry.charCodeAt(0);
319
328
  inputmask.ignorable = false; //make sure ignorable is ignored ;-)
320
329
  EventHandlers.keypressEvent.call(input, keypress);
321
330
  });
@@ -373,7 +382,7 @@ var EventHandlers = {
373
382
  if (opts.positionCaretOnTab === true && inputmask.mouseEnter === false && (!isComplete.call(inputmask, getBuffer.call(inputmask)) || getLastValidPosition.call(inputmask) === -1)) {
374
383
  EventHandlers.clickEvent.apply(input, [e, true]);
375
384
  }
376
- inputmask.undoValue = getBuffer.call(inputmask).join("");
385
+ inputmask.undoValue = inputmask._valueGet(true);
377
386
  },
378
387
  invalidEvent: function (e) {
379
388
  this.inputmask.validationEvent = true;
@@ -383,7 +392,7 @@ var EventHandlers = {
383
392
 
384
393
  var input = this;
385
394
  inputmask.mouseEnter = false;
386
- if (opts.clearMaskOnLostFocus && (input.inputmask.shadowRoot || document).activeElement !== input) {
395
+ if (opts.clearMaskOnLostFocus && (input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
387
396
  HandleNativePlaceholder(input, inputmask.originalPlaceholder);
388
397
  }
389
398
  },
@@ -391,7 +400,7 @@ var EventHandlers = {
391
400
  const inputmask = this.inputmask;
392
401
 
393
402
  var input = this;
394
- if ((input.inputmask.shadowRoot || document).activeElement === input) {
403
+ if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement === input) {
395
404
  var newCaretPosition = determineNewCaretPosition.call(inputmask, caret.call(inputmask, input), tabbed);
396
405
  if (newCaretPosition !== undefined) {
397
406
  caret.call(inputmask, input, newCaretPosition);
@@ -405,15 +414,15 @@ var EventHandlers = {
405
414
  pos = caret.call(inputmask, input);
406
415
 
407
416
  //correct clipboardData
408
- var clipboardData = window.clipboardData || e.clipboardData,
409
- clipData = inputmask.isRTL ? getBuffer.call(inputmask).slice(pos.end, pos.begin) : getBuffer.call(inputmask).slice(pos.begin, pos.end);
410
- clipboardData.setData("text", inputmask.isRTL ? clipData.reverse().join("") : clipData.join(""));
411
- if (document.execCommand) document.execCommand("copy"); // copy selected content to system clipbaord
412
-
417
+ var clipData = inputmask.isRTL ? getBuffer.call(inputmask).slice(pos.end, pos.begin) : getBuffer.call(inputmask).slice(pos.begin, pos.end),
418
+ clipDataText = inputmask.isRTL ? clipData.reverse().join("") : clipData.join("");
419
+ if (window.navigator.clipboard) window.navigator.clipboard.writeText(clipDataText);
420
+ else if (window.clipboardData && window.clipboardData.getData) { // IE
421
+ window.clipboardData.setData("Text", clipDataText);
422
+ }
413
423
  handleRemove.call(inputmask, input, keyCode.DELETE, pos);
414
- writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== getBuffer.call(inputmask).join(""));
415
- }
416
- ,
424
+ writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== inputmask._valueGet(true));
425
+ },
417
426
  blurEvent: function (e) {
418
427
  const inputmask = this.inputmask, opts = inputmask.opts, $ = inputmask.dependencyLib;
419
428
 
@@ -450,8 +459,8 @@ var EventHandlers = {
450
459
  writeBuffer(input, buffer, undefined, e);
451
460
  }
452
461
 
453
- if (inputmask.undoValue !== getBuffer.call(inputmask).join("")) {
454
- inputmask.undoValue = getBuffer.call(inputmask).join("");
462
+ if (inputmask.undoValue !== inputmask._valueGet(true)) {
463
+ inputmask.undoValue = inputmask._valueGet(true);
455
464
  $input.trigger("change");
456
465
  }
457
466
  }
@@ -462,12 +471,13 @@ var EventHandlers = {
462
471
 
463
472
  var input = this;
464
473
  inputmask.mouseEnter = true;
465
- if ((input.inputmask.shadowRoot || document).activeElement !== input) {
466
- if (inputmask.originalPlaceholder == undefined && input.placeholder !== inputmask.originalPlaceholder) {
474
+ if ((input.inputmask.shadowRoot || input.ownerDocument).activeElement !== input) {
475
+ var bufferTemplate = (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join("");
476
+ if (inputmask.placeholder !== bufferTemplate && input.placeholder !== inputmask.originalPlaceholder) {
467
477
  inputmask.originalPlaceholder = input.placeholder;
468
478
  }
469
479
  if (opts.showMaskOnHover) {
470
- HandleNativePlaceholder(input, (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join(""));
480
+ HandleNativePlaceholder(input, bufferTemplate);
471
481
  }
472
482
  }
473
483
  }
@@ -475,10 +485,10 @@ var EventHandlers = {
475
485
  submitEvent: function () { //trigger change on submit if any
476
486
  const inputmask = this.inputmask, opts = inputmask.opts;
477
487
 
478
- if (inputmask.undoValue !== getBuffer.call(inputmask).join("")) {
488
+ if (inputmask.undoValue !== inputmask._valueGet(true)) {
479
489
  inputmask.$el.trigger("change");
480
490
  }
481
- if (opts.clearMaskOnLostFocus && getLastValidPosition.call(inputmask) === -1 && inputmask._valueGet && inputmask._valueGet() === getBufferTemplate.call(inputmask).join("")) {
491
+ if (/*opts.clearMaskOnLostFocus && */getLastValidPosition.call(inputmask) === -1 && inputmask._valueGet && inputmask._valueGet() === getBufferTemplate.call(inputmask).join("")) {
482
492
  inputmask._valueSet(""); //clear masktemplete on submit and still has focus
483
493
  }
484
494
  if (opts.clearIncomplete && isComplete.call(inputmask, getBuffer.call(inputmask)) === false) {
@@ -490,7 +500,8 @@ var EventHandlers = {
490
500
  writeBuffer(inputmask.el, getBuffer.call(inputmask));
491
501
  }, 0);
492
502
  }
493
- },
503
+ }
504
+ ,
494
505
  resetEvent: function () {
495
506
  const inputmask = this.inputmask;
496
507
 
@@ -15,15 +15,14 @@ var EventRuler = {
15
15
  arguments[0] = e;
16
16
  }
17
17
  // console.log(e.type);
18
- var that = this, args, inputmask = that.inputmask, opts = inputmask ? inputmask.opts : undefined,
19
- $ = inputmask.dependencyLib;
18
+ var that = this, args, inputmask = that.inputmask, opts = inputmask ? inputmask.opts : undefined;
20
19
  if (inputmask === undefined && this.nodeName !== "FORM") { //happens when cloning an object with jquery.clone
21
20
  var imOpts = $.data(that, "_inputmask_opts");
22
21
  $(that).off(); //unbind all events
23
22
  if (imOpts) {
24
23
  (new Inputmask(imOpts)).mask(that);
25
24
  }
26
- } else if (e.type !== "setvalue" && this.nodeName !== "FORM" && (that.disabled || (that.readOnly && !(e.type === "keydown" && (e.ctrlKey && e.keyCode === 67) || (opts.tabThrough === false && e.keyCode === keyCode.TAB))))) {
25
+ } else if (!["submit", "reset", "setvalue"].includes(e.type) && this.nodeName !== "FORM" && (that.disabled || (that.readOnly && !(e.type === "keydown" && (e.ctrlKey && e.keyCode === 67) || (opts.tabThrough === false && e.keyCode === keyCode.TAB))))) {
27
26
  e.preventDefault();
28
27
  } else {
29
28
  switch (e.type) {
@@ -67,7 +66,7 @@ var EventRuler = {
67
66
  HandleNativePlaceholder(input, (inputmask.isRTL ? getBufferTemplate.call(inputmask).slice().reverse() : getBufferTemplate.call(inputmask)).join(""));
68
67
  setTimeout(function () {
69
68
  input.focus();
70
- }, 3000);
69
+ }, opts.validationEventTimeOut);
71
70
  return false;
72
71
  }
73
72
  args = arguments;
@@ -88,15 +87,17 @@ var EventRuler = {
88
87
  return returnVal;
89
88
  }
90
89
  };
91
- //keep instance of the event
92
- input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
93
- input.inputmask.events[eventName].push(ev);
94
-
95
90
  if (["submit", "reset"].includes(eventName)) {
96
- if (input.form !== null) $(input.form).on(eventName, ev.bind(input));
91
+ ev = ev.bind(input); //bind creates a new eventhandler (wrap)
92
+ if (input.form !== null) $(input.form).on(eventName, ev);
97
93
  } else {
98
94
  $(input).on(eventName, ev);
99
95
  }
96
+
97
+ //keep instance of the event
98
+ input.inputmask.events[eventName] = input.inputmask.events[eventName] || [];
99
+ input.inputmask.events[eventName].push(ev);
100
+
100
101
  },
101
102
  off: function (input, event) {
102
103
  if (input.inputmask && input.inputmask.events) {