Browse Source

Dynamically changing mask based on number of entered characters fix #1336

Robin Herbots 9 years ago
parent
commit
900aa9fc7f

+ 1 - 0
CHANGELOG.md

@@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
 	- use selective caching in getTests
 	- use selective caching in getTests
 
 
 ### Fixed
 ### Fixed
+- Dynamically changing mask based on number of entered characters #1336
 - change addEventListener not fired in IE11 #1310 - inputmask.dependencyLib.js
 - change addEventListener not fired in IE11 #1310 - inputmask.dependencyLib.js
 - Hide mask's items that have multiple options #678
 - Hide mask's items that have multiple options #678
 - Bug when typing after a fixed character #1299
 - Bug when typing after a fixed character #1299

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.3.2-80",
+  "version": "3.3.2-82",
   "main": [
   "main": [
     "./dist/inputmask/inputmask.js"
     "./dist/inputmask/inputmask.js"
   ],
   ],

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
   "name": "jquery_inputmask",
   "name": "jquery_inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "repository": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-80",
+  "version": "3.3.2-82",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "main": "./dist/jquery.inputmask.bundle.js",
   "main": "./dist/jquery.inputmask.bundle.js",
   "scripts": [
   "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
 {
   "name": "robinherbots/jquery.inputmask",
   "name": "robinherbots/jquery.inputmask",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "version": "3.3.2-80",
+  "version": "3.3.2-82",
   "type": "library",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/jquery.inputmask",
   "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.dependencyLib.jquery.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);

+ 1 - 1
dist/inputmask/inputmask.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 11 - 9
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery")) : factory(window.dependencyLib || jQuery);
@@ -413,7 +413,7 @@
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                         for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                         for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                             var altMatch2 = malternateMatches[ndx2];
                                             var altMatch2 = malternateMatches[ndx2];
-                                            if (("string" != typeof altIndex || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) && (altMatch.match.def === altMatch2.match.def || staticCanMatchDefinition(altMatch, altMatch2))) {
+                                            if (("string" != typeof altIndex || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) && (altMatch.match.def === altMatch2.match.def || opts.keepStatic !== !0 && staticCanMatchDefinition(altMatch, altMatch2))) {
                                                 hasMatch = altMatch.match.mask === altMatch2.match.mask, altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
                                                 hasMatch = altMatch.match.mask === altMatch2.match.mask, altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
                                                 altMatch2.alternation = altMatch.alternation);
                                                 altMatch2.alternation = altMatch.alternation);
                                                 break;
                                                 break;
@@ -589,18 +589,20 @@
                     $.each(getTests(decisionPos, prevPos ? prevPos.locator : void 0, decisionPos - 1), function(ndx, test) {
                     $.each(getTests(decisionPos, prevPos ? prevPos.locator : void 0, decisionPos - 1), function(ndx, test) {
                         altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                         altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                         for (var mndx = 0; mndx < altNdxs.length; mndx++) {
                         for (var mndx = 0; mndx < altNdxs.length; mndx++) {
-                            var validInputs = [], staticInputsAfterPos = 0, staticInputsAfterPosAlternate = 0;
+                            var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
                             if (decisionTaker < altNdxs[mndx]) {
                             if (decisionTaker < altNdxs[mndx]) {
                                 getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                 getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                 var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                 var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                 for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
                                 for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
-                                null == test.match.fn ? (possibilityPos.input !== test.match.def && validInputs.push(possibilityPos.input), 
-                                staticInputsAfterPosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !0, 
+                                null == test.match.fn ? (possibilityPos.input !== test.match.def && (verifyValidInput = !0, 
+                                possibilityPos.generatedInput !== !0 && validInputs.push(possibilityPos.input)), 
+                                staticInputsBeforePosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !0, 
                                 getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input, 
                                 getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input, 
                                 i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i], 
                                 i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                validPos && validPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsAfterPos++, 
+                                validPos && validPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsBeforePos++, 
                                 delete getMaskSet().validPositions[i];
                                 delete getMaskSet().validPositions[i];
-                                for (resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
+                                for (verifyValidInput && validInputs[0] === test.match.def && validInputs.shift(), 
+                                resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
                                     var input = validInputs.shift();
                                     var input = validInputs.shift();
                                     if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid, !0))) break;
                                     if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid, !0))) break;
                                 }
                                 }
@@ -608,8 +610,8 @@
                                     getMaskSet().validPositions[decisionPos].locator = possibilities;
                                     getMaskSet().validPositions[decisionPos].locator = possibilities;
                                     var targetLvp = getLastValidPosition(pos) + 1;
                                     var targetLvp = getLastValidPosition(pos) + 1;
                                     for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
                                     for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                    (void 0 === validPos || null == validPos.match.fn) && i < pos && staticInputsAfterPosAlternate++;
-                                    pos += staticInputsAfterPosAlternate - staticInputsAfterPos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
+                                    (void 0 === validPos || null == validPos.match.fn) && i < pos + (staticInputsBeforePosAlternate - staticInputsBeforePos) && staticInputsBeforePosAlternate++;
+                                    pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
                                 }
                                 }
                                 if (isValidRslt) return !1;
                                 if (isValidRslt) return !1;
                                 resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
                                 resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);

+ 1 - 1
dist/inputmask/inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "inputmask.dependencyLib", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("./inputmask.dependencyLib.jquery"), require("./inputmask")) : factory(window.dependencyLib || jQuery, window.Inputmask);

+ 1 - 1
dist/inputmask/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(factory) {
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);
     "function" == typeof define && define.amd ? define([ "jquery", "inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery, window.Inputmask);

+ 11 - 9
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function($) {
 !function($) {
     function Inputmask(alias, options) {
     function Inputmask(alias, options) {
@@ -411,7 +411,7 @@
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                         altMatch.alternation = altMatch.alternation || loopNdxCnt;
                                         for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                         for (var ndx2 = 0; ndx2 < malternateMatches.length; ndx2++) {
                                             var altMatch2 = malternateMatches[ndx2];
                                             var altMatch2 = malternateMatches[ndx2];
-                                            if (("string" != typeof altIndex || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) && (altMatch.match.def === altMatch2.match.def || staticCanMatchDefinition(altMatch, altMatch2))) {
+                                            if (("string" != typeof altIndex || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) && (altMatch.match.def === altMatch2.match.def || opts.keepStatic !== !0 && staticCanMatchDefinition(altMatch, altMatch2))) {
                                                 hasMatch = altMatch.match.mask === altMatch2.match.mask, altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
                                                 hasMatch = altMatch.match.mask === altMatch2.match.mask, altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1 && (altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation], 
                                                 altMatch2.alternation = altMatch.alternation);
                                                 altMatch2.alternation = altMatch.alternation);
                                                 break;
                                                 break;
@@ -587,18 +587,20 @@
                     $.each(getTests(decisionPos, prevPos ? prevPos.locator : void 0, decisionPos - 1), function(ndx, test) {
                     $.each(getTests(decisionPos, prevPos ? prevPos.locator : void 0, decisionPos - 1), function(ndx, test) {
                         altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                         altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
                         for (var mndx = 0; mndx < altNdxs.length; mndx++) {
                         for (var mndx = 0; mndx < altNdxs.length; mndx++) {
-                            var validInputs = [], staticInputsAfterPos = 0, staticInputsAfterPosAlternate = 0;
+                            var validInputs = [], staticInputsBeforePos = 0, staticInputsBeforePosAlternate = 0, verifyValidInput = !1;
                             if (decisionTaker < altNdxs[mndx]) {
                             if (decisionTaker < altNdxs[mndx]) {
                                 getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                 getMaskSet().validPositions[decisionPos] = $.extend(!0, {}, test);
                                 var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                 var possibilities = getMaskSet().validPositions[decisionPos].locator;
                                 for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
                                 for (getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]), 
-                                null == test.match.fn ? (possibilityPos.input !== test.match.def && validInputs.push(possibilityPos.input), 
-                                staticInputsAfterPosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !0, 
+                                null == test.match.fn ? (possibilityPos.input !== test.match.def && (verifyValidInput = !0, 
+                                possibilityPos.generatedInput !== !0 && validInputs.push(possibilityPos.input)), 
+                                staticInputsBeforePosAlternate++, getMaskSet().validPositions[decisionPos].generatedInput = !0, 
                                 getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input, 
                                 getMaskSet().validPositions[decisionPos].input = test.match.def) : getMaskSet().validPositions[decisionPos].input = possibilityPos.input, 
                                 i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i], 
                                 i = decisionPos + 1; i < getLastValidPosition(void 0, !0) + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                validPos && validPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsAfterPos++, 
+                                validPos && validPos.generatedInput !== !0 && /[0-9a-bA-Z]/.test(validPos.input) ? validInputs.push(validPos.input) : i < pos && staticInputsBeforePos++, 
                                 delete getMaskSet().validPositions[i];
                                 delete getMaskSet().validPositions[i];
-                                for (resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
+                                for (verifyValidInput && validInputs[0] === test.match.def && validInputs.shift(), 
+                                resetMaskSet(!0), isValidRslt = !0; validInputs.length > 0; ) {
                                     var input = validInputs.shift();
                                     var input = validInputs.shift();
                                     if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid, !0))) break;
                                     if (input !== opts.skipOptionalPartCharacter && !(isValidRslt = isValid(getLastValidPosition(void 0, !0) + 1, input, !1, fromSetValid, !0))) break;
                                 }
                                 }
@@ -606,8 +608,8 @@
                                     getMaskSet().validPositions[decisionPos].locator = possibilities;
                                     getMaskSet().validPositions[decisionPos].locator = possibilities;
                                     var targetLvp = getLastValidPosition(pos) + 1;
                                     var targetLvp = getLastValidPosition(pos) + 1;
                                     for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
                                     for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) validPos = getMaskSet().validPositions[i], 
-                                    (void 0 === validPos || null == validPos.match.fn) && i < pos && staticInputsAfterPosAlternate++;
-                                    pos += staticInputsAfterPosAlternate - staticInputsAfterPos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
+                                    (void 0 === validPos || null == validPos.match.fn) && i < pos + (staticInputsBeforePosAlternate - staticInputsBeforePos) && staticInputsBeforePosAlternate++;
+                                    pos += staticInputsBeforePosAlternate - staticInputsBeforePos, isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, !0);
                                 }
                                 }
                                 if (isValidRslt) return !1;
                                 if (isValidRslt) return !1;
                                 resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);
                                 resetMaskSet(), getMaskSet().validPositions = $.extend(!0, {}, validPsClone);

+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  Input Mask plugin extensions
  Input Mask plugin extensions

+ 1 - 1
dist/min/inputmask/inputmask.dependencyLib.jquery.min.js

@@ -3,6 +3,6 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});
 !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return window.dependencyLib=a,a});

+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  Input Mask plugin extensions
  Input Mask plugin extensions

+ 7 - 6
dist/min/inputmask/inputmask.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  * Input Mask Core
  * Input Mask Core
@@ -94,7 +94,7 @@ var G=a.inArray(f,c.matches)+1;c.matches.length>G&&(f=j(c.matches[G],[G].concat(
 //fuzzy merge matches
 //fuzzy merge matches
 for(var H=0;H<u.length;H++){var I=u[H],J=!1;I.alternation=I.alternation||z;for(var K=0;K<x.length;K++){var L=x[K];
 for(var H=0;H<u.length;H++){var I=u[H],J=!1;I.alternation=I.alternation||z;for(var K=0;K<x.length;K++){var L=x[K];
 //verify equality
 //verify equality
-if(("string"!=typeof A||a.inArray(I.locator[I.alternation].toString(),E)!==-1)&&(I.match.def===L.match.def||s(I,L))){J=I.match.mask===L.match.mask,L.locator[I.alternation].toString().indexOf(I.locator[I.alternation])===-1&&(L.locator[I.alternation]=L.locator[I.alternation]+","+I.locator[I.alternation],L.alternation=I.alternation);break}}J||x.push(I)}}"string"==typeof A&&(//filter matches
+if(("string"!=typeof A||a.inArray(I.locator[I.alternation].toString(),E)!==-1)&&(I.match.def===L.match.def||g.keepStatic!==!0&&s(I,L))){J=I.match.mask===L.match.mask,L.locator[I.alternation].toString().indexOf(I.locator[I.alternation])===-1&&(L.locator[I.alternation]=L.locator[I.alternation]+","+I.locator[I.alternation],L.alternation=I.alternation);break}}J||x.push(I)}}"string"==typeof A&&(//filter matches
 x=a.map(x,function(b,c){if(isFinite(c)){var d,e=b.alternation,f=b.locator[e].toString().split(",");b.locator[e]=void 0,b.alternation=void 0;for(var g=0;g<f.length;g++)d=a.inArray(f[g],E)!==-1,d&&(//rebuild the locator with valid entries
 x=a.map(x,function(b,c){if(isFinite(c)){var d,e=b.alternation,f=b.locator[e].toString().split(",");b.locator[e]=void 0,b.alternation=void 0;for(var g=0;g<f.length;g++)d=a.inArray(f[g],E)!==-1,d&&(//rebuild the locator with valid entries
 void 0!==b.locator[e]?(b.locator[e]+=",",b.locator[e]+=f[g]):b.locator[e]=parseInt(f[g]),b.alternation=e);if(void 0!==b.locator[e])return b}})),n=y.concat(x),k=b,o=n.length>0,//insert a stopelemnt when there is an alternate - needed for non-greedy option
 void 0!==b.locator[e]?(b.locator[e]+=",",b.locator[e]+=f[g]):b.locator[e]=parseInt(f[g]),b.alternation=e);if(void 0!==b.locator[e])return b}})),n=y.concat(x),k=b,o=n.length>0,//insert a stopelemnt when there is an alternate - needed for non-greedy option
 //cloneback
 //cloneback
@@ -126,10 +126,11 @@ return h=a.extend(h,C(v,u,!0)),!1;return(h===!0||void 0!==h.pos||void 0!==h.c)&&
 //find last modified alternation
 //find last modified alternation
 j=m().validPositions[t];t>=0;t--)if(i=m().validPositions[t],i&&void 0!==i.alternation){if(e=t,h=m().validPositions[e].alternation,j.locator[i.alternation]!==i.locator[i.alternation])break;j=i}if(void 0!==h){q=parseInt(e);var u=void 0!==j.locator[j.alternation||h]?j.locator[j.alternation||h]:p[0];//no match in the alternations (length mismatch)
 j=m().validPositions[t];t>=0;t--)if(i=m().validPositions[t],i&&void 0!==i.alternation){if(e=t,h=m().validPositions[e].alternation,j.locator[i.alternation]!==i.locator[i.alternation])break;j=i}if(void 0!==h){q=parseInt(e);var u=void 0!==j.locator[j.alternation||h]?j.locator[j.alternation||h]:p[0];//no match in the alternations (length mismatch)
 u.length>0&&(//no decision taken ~ take first one as decider
 u.length>0&&(//no decision taken ~ take first one as decider
-u=u.split(",")[0]);var v=m().validPositions[q],x=m().validPositions[q-1];a.each(w(q,x?x.locator:void 0,q-1),function(e,i){p=i.locator[h]?i.locator[h].toString().split(","):[];for(var j=0;j<p.length;j++){var t=[],w=0,x=0;if(u<p[j]){m().validPositions[q]=a.extend(!0,{},i);var y=m().validPositions[q].locator;for(m().validPositions[q].locator[h]=parseInt(p[j]),//set forced decision
-null==i.match.fn?(v.input!==i.match.def&&t.push(v.input),x++,m().validPositions[q].generatedInput=!0,m().validPositions[q].input=i.match.def):m().validPositions[q].input=v.input,k=q+1;k<o(void 0,!0)+1;k++)l=m().validPositions[k],l&&l.generatedInput!==!0&&/[0-9a-bA-Z]/.test(l.input)?t.push(l.input):k<b&&w++,delete m().validPositions[k];for(n(!0),//clear getbuffer
-s=!0;t.length>0;){var z=t.shift();if(z!==g.skipOptionalPartCharacter&&!(s=C(o(void 0,!0)+1,z,!1,f,!0)))break}if(s){m().validPositions[q].locator=y;//reset forceddecision ~ needed for proper delete
-var A=o(b)+1;for(k=q+1;k<o()+1;k++)l=m().validPositions[k],(void 0===l||null==l.match.fn)&&k<b&&x++;b+=x-w,s=C(b>A?A:b,c,d,f,!0)}if(s)return!1;n(),m().validPositions=a.extend(!0,{},r)}}})}return s}
+u=u.split(",")[0]);var v=m().validPositions[q],x=m().validPositions[q-1];a.each(w(q,x?x.locator:void 0,q-1),function(e,i){p=i.locator[h]?i.locator[h].toString().split(","):[];for(var j=0;j<p.length;j++){var t=[],w=0,x=0,y=!1;if(u<p[j]){m().validPositions[q]=a.extend(!0,{},i);var z=m().validPositions[q].locator;for(m().validPositions[q].locator[h]=parseInt(p[j]),//set forced decision
+null==i.match.fn?(v.input!==i.match.def&&(y=!0,//verify that the new definition matches the input
+v.generatedInput!==!0&&t.push(v.input)),x++,m().validPositions[q].generatedInput=!0,m().validPositions[q].input=i.match.def):m().validPositions[q].input=v.input,k=q+1;k<o(void 0,!0)+1;k++)l=m().validPositions[k],l&&l.generatedInput!==!0&&/[0-9a-bA-Z]/.test(l.input)?t.push(l.input):k<b&&w++,delete m().validPositions[k];for(y&&t[0]===i.match.def&&t.shift(),n(!0),//clear getbuffer
+s=!0;t.length>0;){var A=t.shift();if(A!==g.skipOptionalPartCharacter&&!(s=C(o(void 0,!0)+1,A,!1,f,!0)))break}if(s){m().validPositions[q].locator=z;//reset forceddecision ~ needed for proper delete
+var B=o(b)+1;for(k=q+1;k<o()+1;k++)l=m().validPositions[k],(void 0===l||null==l.match.fn)&&k<b+(x-w)&&x++;b+=x-w,s=C(b>B?B:b,c,d,f,!0)}if(s)return!1;n(),m().validPositions=a.extend(!0,{},r)}}})}return s}
 //set alternator choice on previous skipped placeholder positions
 //set alternator choice on previous skipped placeholder positions
 function l(b,c){for(var d=m().validPositions[c],e=d.locator,f=e.length,g=b;g<c;g++)if(void 0===m().validPositions[g]&&!D(g,!0)){var h=w(g),i=h[0],j=-1;a.each(h,function(a,b){//find best matching
 function l(b,c){for(var d=m().validPositions[c],e=d.locator,f=e.length,g=b;g<c;g++)if(void 0===m().validPositions[g]&&!D(g,!0)){var h=w(g),i=h[0],j=-1;a.each(h,function(a,b){//find best matching
 for(var c=0;c<f&&(void 0!==b.locator[c]&&B(b.locator[c].toString().split(","),e[c].toString().split(",")));c++)j<c&&(j=c,i=b)}),p(g,a.extend({},i,{input:i.match.placeholder||i.match.def}),!0)}}e=e===!0;//always set a value to strict to prevent possible strange behavior in the extensions
 for(var c=0;c<f&&(void 0!==b.locator[c]&&B(b.locator[c].toString().split(","),e[c].toString().split(",")));c++)j<c&&(j=c,i=b)}),p(g,a.extend({},i,{input:i.match.placeholder||i.match.def}),!0)}}e=e===!0;//always set a value to strict to prevent possible strange behavior in the extensions

+ 1 - 1
dist/min/inputmask/inputmask.numeric.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  Input Mask plugin extensions
  Input Mask plugin extensions

+ 1 - 1
dist/min/inputmask/inputmask.phone.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  Input Mask plugin extensions
  Input Mask plugin extensions

+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  Input Mask plugin extensions
  Input Mask plugin extensions

+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  * Input Mask plugin for jquery
  * Input Mask plugin for jquery

+ 7 - 6
dist/min/jquery.inputmask.bundle.min.js

@@ -3,7 +3,7 @@
 * https://github.com/RobinHerbots/jquery.inputmask
 * https://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Copyright (c) 2010 - 2016 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.3.2-80
+* Version: 3.3.2-82
 */
 */
 /*
 /*
  * Input Mask Core
  * Input Mask Core
@@ -94,7 +94,7 @@ var G=a.inArray(f,c.matches)+1;c.matches.length>G&&(f=j(c.matches[G],[G].concat(
 //fuzzy merge matches
 //fuzzy merge matches
 for(var H=0;H<u.length;H++){var I=u[H],J=!1;I.alternation=I.alternation||z;for(var K=0;K<x.length;K++){var L=x[K];
 for(var H=0;H<u.length;H++){var I=u[H],J=!1;I.alternation=I.alternation||z;for(var K=0;K<x.length;K++){var L=x[K];
 //verify equality
 //verify equality
-if(("string"!=typeof A||a.inArray(I.locator[I.alternation].toString(),E)!==-1)&&(I.match.def===L.match.def||s(I,L))){J=I.match.mask===L.match.mask,L.locator[I.alternation].toString().indexOf(I.locator[I.alternation])===-1&&(L.locator[I.alternation]=L.locator[I.alternation]+","+I.locator[I.alternation],L.alternation=I.alternation);break}}J||x.push(I)}}"string"==typeof A&&(//filter matches
+if(("string"!=typeof A||a.inArray(I.locator[I.alternation].toString(),E)!==-1)&&(I.match.def===L.match.def||g.keepStatic!==!0&&s(I,L))){J=I.match.mask===L.match.mask,L.locator[I.alternation].toString().indexOf(I.locator[I.alternation])===-1&&(L.locator[I.alternation]=L.locator[I.alternation]+","+I.locator[I.alternation],L.alternation=I.alternation);break}}J||x.push(I)}}"string"==typeof A&&(//filter matches
 x=a.map(x,function(b,c){if(isFinite(c)){var d,e=b.alternation,f=b.locator[e].toString().split(",");b.locator[e]=void 0,b.alternation=void 0;for(var g=0;g<f.length;g++)d=a.inArray(f[g],E)!==-1,d&&(//rebuild the locator with valid entries
 x=a.map(x,function(b,c){if(isFinite(c)){var d,e=b.alternation,f=b.locator[e].toString().split(",");b.locator[e]=void 0,b.alternation=void 0;for(var g=0;g<f.length;g++)d=a.inArray(f[g],E)!==-1,d&&(//rebuild the locator with valid entries
 void 0!==b.locator[e]?(b.locator[e]+=",",b.locator[e]+=f[g]):b.locator[e]=parseInt(f[g]),b.alternation=e);if(void 0!==b.locator[e])return b}})),n=y.concat(x),k=b,o=n.length>0,//insert a stopelemnt when there is an alternate - needed for non-greedy option
 void 0!==b.locator[e]?(b.locator[e]+=",",b.locator[e]+=f[g]):b.locator[e]=parseInt(f[g]),b.alternation=e);if(void 0!==b.locator[e])return b}})),n=y.concat(x),k=b,o=n.length>0,//insert a stopelemnt when there is an alternate - needed for non-greedy option
 //cloneback
 //cloneback
@@ -126,10 +126,11 @@ return h=a.extend(h,C(v,u,!0)),!1;return(h===!0||void 0!==h.pos||void 0!==h.c)&&
 //find last modified alternation
 //find last modified alternation
 j=m().validPositions[t];t>=0;t--)if(i=m().validPositions[t],i&&void 0!==i.alternation){if(e=t,h=m().validPositions[e].alternation,j.locator[i.alternation]!==i.locator[i.alternation])break;j=i}if(void 0!==h){q=parseInt(e);var u=void 0!==j.locator[j.alternation||h]?j.locator[j.alternation||h]:p[0];//no match in the alternations (length mismatch)
 j=m().validPositions[t];t>=0;t--)if(i=m().validPositions[t],i&&void 0!==i.alternation){if(e=t,h=m().validPositions[e].alternation,j.locator[i.alternation]!==i.locator[i.alternation])break;j=i}if(void 0!==h){q=parseInt(e);var u=void 0!==j.locator[j.alternation||h]?j.locator[j.alternation||h]:p[0];//no match in the alternations (length mismatch)
 u.length>0&&(//no decision taken ~ take first one as decider
 u.length>0&&(//no decision taken ~ take first one as decider
-u=u.split(",")[0]);var v=m().validPositions[q],x=m().validPositions[q-1];a.each(w(q,x?x.locator:void 0,q-1),function(e,i){p=i.locator[h]?i.locator[h].toString().split(","):[];for(var j=0;j<p.length;j++){var t=[],w=0,x=0;if(u<p[j]){m().validPositions[q]=a.extend(!0,{},i);var y=m().validPositions[q].locator;for(m().validPositions[q].locator[h]=parseInt(p[j]),//set forced decision
-null==i.match.fn?(v.input!==i.match.def&&t.push(v.input),x++,m().validPositions[q].generatedInput=!0,m().validPositions[q].input=i.match.def):m().validPositions[q].input=v.input,k=q+1;k<o(void 0,!0)+1;k++)l=m().validPositions[k],l&&l.generatedInput!==!0&&/[0-9a-bA-Z]/.test(l.input)?t.push(l.input):k<b&&w++,delete m().validPositions[k];for(n(!0),//clear getbuffer
-s=!0;t.length>0;){var z=t.shift();if(z!==g.skipOptionalPartCharacter&&!(s=C(o(void 0,!0)+1,z,!1,f,!0)))break}if(s){m().validPositions[q].locator=y;//reset forceddecision ~ needed for proper delete
-var A=o(b)+1;for(k=q+1;k<o()+1;k++)l=m().validPositions[k],(void 0===l||null==l.match.fn)&&k<b&&x++;b+=x-w,s=C(b>A?A:b,c,d,f,!0)}if(s)return!1;n(),m().validPositions=a.extend(!0,{},r)}}})}return s}
+u=u.split(",")[0]);var v=m().validPositions[q],x=m().validPositions[q-1];a.each(w(q,x?x.locator:void 0,q-1),function(e,i){p=i.locator[h]?i.locator[h].toString().split(","):[];for(var j=0;j<p.length;j++){var t=[],w=0,x=0,y=!1;if(u<p[j]){m().validPositions[q]=a.extend(!0,{},i);var z=m().validPositions[q].locator;for(m().validPositions[q].locator[h]=parseInt(p[j]),//set forced decision
+null==i.match.fn?(v.input!==i.match.def&&(y=!0,//verify that the new definition matches the input
+v.generatedInput!==!0&&t.push(v.input)),x++,m().validPositions[q].generatedInput=!0,m().validPositions[q].input=i.match.def):m().validPositions[q].input=v.input,k=q+1;k<o(void 0,!0)+1;k++)l=m().validPositions[k],l&&l.generatedInput!==!0&&/[0-9a-bA-Z]/.test(l.input)?t.push(l.input):k<b&&w++,delete m().validPositions[k];for(y&&t[0]===i.match.def&&t.shift(),n(!0),//clear getbuffer
+s=!0;t.length>0;){var A=t.shift();if(A!==g.skipOptionalPartCharacter&&!(s=C(o(void 0,!0)+1,A,!1,f,!0)))break}if(s){m().validPositions[q].locator=z;//reset forceddecision ~ needed for proper delete
+var B=o(b)+1;for(k=q+1;k<o()+1;k++)l=m().validPositions[k],(void 0===l||null==l.match.fn)&&k<b+(x-w)&&x++;b+=x-w,s=C(b>B?B:b,c,d,f,!0)}if(s)return!1;n(),m().validPositions=a.extend(!0,{},r)}}})}return s}
 //set alternator choice on previous skipped placeholder positions
 //set alternator choice on previous skipped placeholder positions
 function l(b,c){for(var d=m().validPositions[c],e=d.locator,f=e.length,g=b;g<c;g++)if(void 0===m().validPositions[g]&&!D(g,!0)){var h=w(g),i=h[0],j=-1;a.each(h,function(a,b){//find best matching
 function l(b,c){for(var d=m().validPositions[c],e=d.locator,f=e.length,g=b;g<c;g++)if(void 0===m().validPositions[g]&&!D(g,!0)){var h=w(g),i=h[0],j=-1;a.each(h,function(a,b){//find best matching
 for(var c=0;c<f&&(void 0!==b.locator[c]&&B(b.locator[c].toString().split(","),e[c].toString().split(",")));c++)j<c&&(j=c,i=b)}),p(g,a.extend({},i,{input:i.match.placeholder||i.match.def}),!0)}}e=e===!0;//always set a value to strict to prevent possible strange behavior in the extensions
 for(var c=0;c<f&&(void 0!==b.locator[c]&&B(b.locator[c].toString().split(","),e[c].toString().split(",")));c++)j<c&&(j=c,i=b)}),p(g,a.extend({},i,{input:i.match.placeholder||i.match.def}),!0)}}e=e===!0;//always set a value to strict to prevent possible strange behavior in the extensions

+ 20 - 13
js/inputmask.js

@@ -1084,7 +1084,8 @@
 											var altMatch2 = malternateMatches[ndx2];
 											var altMatch2 = malternateMatches[ndx2];
 											//verify equality
 											//verify equality
 											if (typeof altIndex !== "string" || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) {
 											if (typeof altIndex !== "string" || $.inArray(altMatch.locator[altMatch.alternation].toString(), altIndexArr) !== -1) {
-												if (altMatch.match.def === altMatch2.match.def || staticCanMatchDefinition(altMatch, altMatch2)) {
+												//there is no use to generalize the static definition to a mask definition when using keepStatic ~ prevents proper alternating
+												if (altMatch.match.def === altMatch2.match.def || (opts.keepStatic !== true && staticCanMatchDefinition(altMatch, altMatch2))) {
 													hasMatch = altMatch.match.mask === altMatch2.match.mask;
 													hasMatch = altMatch.match.mask === altMatch2.match.mask;
 													if (altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1) {
 													if (altMatch2.locator[altMatch.alternation].toString().indexOf(altMatch.locator[altMatch.alternation]) === -1) {
 														altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation];
 														altMatch2.locator[altMatch.alternation] = altMatch2.locator[altMatch.alternation] + "," + altMatch.locator[altMatch.alternation];
@@ -1263,7 +1264,6 @@
 			}
 			}
 			getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
 			getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
 			//console.log(pos + " - " + JSON.stringify(matches));
 			//console.log(pos + " - " + JSON.stringify(matches));
-			//keepstatic as from first mask element
 			return filterTests(getMaskSet().tests[pos]);
 			return filterTests(getMaskSet().tests[pos]);
 		}
 		}
 
 
@@ -1470,16 +1470,21 @@
 						altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
 						altNdxs = test.locator[alternation] ? test.locator[alternation].toString().split(",") : [];
 						for (var mndx = 0; mndx < altNdxs.length; mndx++) {
 						for (var mndx = 0; mndx < altNdxs.length; mndx++) {
 							var validInputs = [],
 							var validInputs = [],
-								staticInputsAfterPos = 0,
-								staticInputsAfterPosAlternate = 0;
+								staticInputsBeforePos = 0,
+								staticInputsBeforePosAlternate = 0,
+								verifyValidInput = false;
 							if (decisionTaker < altNdxs[mndx]) {
 							if (decisionTaker < altNdxs[mndx]) {
 								getMaskSet().validPositions[decisionPos] = $.extend(true, {}, test);
 								getMaskSet().validPositions[decisionPos] = $.extend(true, {}, test);
 								var possibilities = getMaskSet().validPositions[decisionPos].locator;
 								var possibilities = getMaskSet().validPositions[decisionPos].locator;
 								getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]); //set forced decision
 								getMaskSet().validPositions[decisionPos].locator[alternation] = parseInt(altNdxs[mndx]); //set forced decision
 								if (test.match.fn == null) {
 								if (test.match.fn == null) {
-									if (possibilityPos.input !== test.match.def)
-										validInputs.push(possibilityPos.input);
-									staticInputsAfterPosAlternate++;
+									if (possibilityPos.input !== test.match.def) {
+										verifyValidInput = true; //verify that the new definition matches the input
+										if (possibilityPos.generatedInput !== true) {
+											validInputs.push(possibilityPos.input);
+										}
+									}
+									staticInputsBeforePosAlternate++;
 									getMaskSet().validPositions[decisionPos].generatedInput = true;
 									getMaskSet().validPositions[decisionPos].generatedInput = true;
 									getMaskSet().validPositions[decisionPos].input = test.match.def;
 									getMaskSet().validPositions[decisionPos].input = test.match.def;
 								} else {
 								} else {
@@ -1489,10 +1494,12 @@
 									validPos = getMaskSet().validPositions[i];
 									validPos = getMaskSet().validPositions[i];
 									if (validPos && validPos.generatedInput !== true && /[0-9a-bA-Z]/.test(validPos.input)) {
 									if (validPos && validPos.generatedInput !== true && /[0-9a-bA-Z]/.test(validPos.input)) {
 										validInputs.push(validPos.input);
 										validInputs.push(validPos.input);
-									} else if (i < pos) staticInputsAfterPos++;
+									} else if (i < pos) staticInputsBeforePos++;
 									delete getMaskSet().validPositions[i];
 									delete getMaskSet().validPositions[i];
 								}
 								}
-
+								if (verifyValidInput && validInputs[0] === test.match.def) {
+									validInputs.shift();
+								}
 								resetMaskSet(true); //clear getbuffer
 								resetMaskSet(true); //clear getbuffer
 								isValidRslt = true;
 								isValidRslt = true;
 								while (validInputs.length > 0) {
 								while (validInputs.length > 0) {
@@ -1509,11 +1516,11 @@
 									var targetLvp = getLastValidPosition(pos) + 1;
 									var targetLvp = getLastValidPosition(pos) + 1;
 									for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
 									for (i = decisionPos + 1; i < getLastValidPosition() + 1; i++) {
 										validPos = getMaskSet().validPositions[i];
 										validPos = getMaskSet().validPositions[i];
-										if ((validPos === undefined || validPos.match.fn == null) && i < pos) {
-											staticInputsAfterPosAlternate++;
+										if ((validPos === undefined || validPos.match.fn == null) && i < (pos + (staticInputsBeforePosAlternate - staticInputsBeforePos))) {
+											staticInputsBeforePosAlternate++;
 										}
 										}
 									}
 									}
-									pos = pos + (staticInputsAfterPosAlternate - staticInputsAfterPos);
+									pos = pos + (staticInputsBeforePosAlternate - staticInputsBeforePos);
 									isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, true);
 									isValidRslt = isValid(pos > targetLvp ? targetLvp : pos, c, strict, fromSetValid, true);
 								}
 								}
 								if (!isValidRslt) {
 								if (!isValidRslt) {
@@ -1803,7 +1810,7 @@
 			});
 			});
 			if (writeOut) {
 			if (writeOut) {
 				var caretPos = document.activeElement === input ? (initiatingEvent ? caret(input).begin : result.forwardPosition) : undefined,
 				var caretPos = document.activeElement === input ? (initiatingEvent ? caret(input).begin : result.forwardPosition) : undefined,
-				offset = getBuffer().length - input.inputmask._valueGet().length;
+					offset = getBuffer().length - input.inputmask._valueGet().length;
 				writeBuffer(input, getBuffer(), caretPos + offset, initiatingEvent || new $.Event("checkval"));
 				writeBuffer(input, getBuffer(), caretPos + offset, initiatingEvent || new $.Event("checkval"));
 			}
 			}
 		}
 		}

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.3.2-80",
+  "version": "3.3.2-82",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [
   "files": [

+ 28 - 0
qunit/tests_keepStatic.js

@@ -338,4 +338,32 @@ define([
 		$("#testmask").Type("1234");
 		$("#testmask").Type("1234");
 		assert.equal(testmask.value, "12+34", "Result " + testmask.value);
 		assert.equal(testmask.value, "12+34", "Result " + testmask.value);
 	});
 	});
+
+	qunit.test("[\"999-9999\", \"(999) 999-9999\", \"1-(999) 999-9999\"] - 999-9999 - carylewis", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask(["999-9999", "(999) 999-9999", "1-(999) 999-9999"]).mask(testmask);
+
+		$("#testmask").Type("1231234");
+		assert.equal(testmask.value, "123-1234", "Result " + testmask.value);
+	});
+	qunit.test("[\"999-9999\", \"(999) 999-9999\", \"1-(999) 999-9999\"] - (999) 999-9999 - carylewis", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask(["999-9999", "(999) 999-9999", "1-(999) 999-9999"]).mask(testmask);
+
+		$("#testmask").Type("1231231234");
+		assert.equal(testmask.value, "(123) 123-1234", "Result " + testmask.value);
+	});
+	qunit.test("[\"999-9999\", \"(999) 999-9999\", \"1-(999) 999-9999\"] - 1-(999) 999-9999 - carylewis", function(assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+		Inputmask(["999-9999", "(999) 999-9999", "1-(999) 999-9999"]).mask(testmask);
+
+		$("#testmask").Type("11231231234");
+		assert.equal(testmask.value, "1-(123) 123-1234", "Result " + testmask.value);
+	});
 });
 });