Browse Source

IE11 clear not working in emulated IE9 mode #1144

Robin Herbots 10 years ago
parent
commit
3ade03f442

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
 - update alternation logic
 
 ### Fixed
+- IE11 clear not working in emulated IE9 mode #1144
 - Show placeholder as user types #1141
 - Initial value like VAA gets truncated to V-__ with mask like "I{1,3}-ZZ" #1134
 - Input mask can't be applied on other HTML5 input types #828

+ 3 - 0
README.md

@@ -274,6 +274,9 @@ You can define the mask as a function which can allow to preprocess the resultin
 
 ### JIT Masking
 Just in time masking.  With the jitMasking option you can enable jit masking.  The mask will only be visible for the user entered characters.
+Default: false
+
+Value can be true or a threshold number or false. 
 
 ```javascript
    Inputmask("date", { jitMasking: true }).mask(selector);

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.2.6-24",
+  "version": "3.2.6-25",
   "main": [
     "./dist/inputmask/inputmask.js"
   ],

+ 1 - 1
component.json

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

+ 1 - 1
composer.json

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

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !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);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !function(factory) {
     "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 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !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);

+ 13 - 8
dist/inputmask/inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !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);
@@ -255,7 +255,7 @@
                     var validPos = getMaskSet().validPositions[pos];
                     test = validPos.match, ndxIntlzr = validPos.locator.slice(), maskTemplate.push(includeInput === !0 ? validPos.input : getPlaceholder(pos, test));
                 } else testPos = getTestTemplate(pos, ndxIntlzr, pos - 1), test = testPos.match, 
-                ndxIntlzr = testPos.locator.slice(), (opts.jitMasking !== !0 || lvp > pos) && maskTemplate.push(getPlaceholder(pos, test));
+                ndxIntlzr = testPos.locator.slice(), (opts.jitMasking === !1 || lvp > pos || isFinite(opts.jitMasking) && opts.jitMasking > pos) && maskTemplate.push(getPlaceholder(pos, test));
                 pos++;
             } while ((void 0 === maxLength || maxLength > pos - 1) && null !== test.fn || null === test.fn && "" !== test.def || minimalPos >= pos);
             return "" === maskTemplate[maskTemplate.length - 1] && maskTemplate.pop(), maskTemplate;
@@ -347,6 +347,12 @@
         function getTests(pos, ndxIntlzr, tstPs, cacheable) {
             function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) {
                 function handleMatch(match, loopNdx, quantifierRecurse) {
+                    function isFirstMatch(latestMatch, tokenGroup) {
+                        var firstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches);
+                        return firstMatch || $.each(tokenGroup.matches, function(ndx, match) {
+                            return match.isQuantifier === !0 && (firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1])) ? !1 : void 0;
+                        }), firstMatch;
+                    }
                     function resolveNdxInitializer(pos, alternateNdx) {
                         var bestMatch = selectBestMatch(pos, alternateNdx);
                         return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
@@ -362,8 +368,7 @@
                         } else if (match.isOptional) {
                             var optionalToken = match;
                             if (match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse)) {
-                                if (latestMatch = matches[matches.length - 1].match, isFirstMatch = 0 === $.inArray(latestMatch, optionalToken.matches), 
-                                !isFirstMatch) return !0;
+                                if (latestMatch = matches[matches.length - 1].match, !isFirstMatch(latestMatch, optionalToken)) return !0;
                                 insertStop = !0, testPos = pos;
                             }
                         } else if (match.isAlternator) {
@@ -415,7 +420,7 @@
                             var tokenGroup = maskToken.matches[$.inArray(qt, maskToken.matches) - 1];
                             if (match = handleMatch(tokenGroup, [ qndx ].concat(loopNdx), tokenGroup)) {
                                 if (latestMatch = matches[matches.length - 1].match, latestMatch.optionalQuantifier = qndx > qt.quantifier.min - 1, 
-                                isFirstMatch = 0 === $.inArray(latestMatch, tokenGroup.matches)) {
+                                isFirstMatch(latestMatch, tokenGroup)) {
                                     if (qndx > qt.quantifier.min - 1) {
                                         insertStop = !0, testPos = pos;
                                         break;
@@ -433,7 +438,7 @@
                     if (testPos > pos) break;
                 }
             }
-            var latestMatch, isFirstMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
+            var latestMatch, maskTokens = getMaskSet().maskToken, testPos = ndxIntlzr ? tstPs : 0, ndxInitializer = ndxIntlzr || [ 0 ], matches = [], insertStop = !1;
             if (pos > -1) {
                 if (cacheable === !0 && getMaskSet().tests[pos]) return getMaskSet().tests[pos];
                 if (void 0 === ndxIntlzr) {
@@ -834,7 +839,7 @@
             function installNativeValueSetFallback(npt) {
                 EventRuler.on(npt, "mouseenter", function(event) {
                     var $input = $(this), input = this, value = input.inputmask._valueGet();
-                    "" !== value && value !== getBuffer().join("") && $input.trigger("setvalue");
+                    value !== getBuffer().join("") && getLastValidPosition() > 0 && $input.trigger("setvalue");
                 });
             }
             var valueGet, valueSet;
@@ -1044,7 +1049,7 @@
             var input = this;
             if (document.activeElement === input) {
                 var selectedCaret = caret(input);
-                if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, $.inArray(opts.radixPoint, getBuffer())); else {
+                if (selectedCaret.begin === selectedCaret.end) if (doRadixFocus(selectedCaret.begin)) caret(input, opts.numericInput ? seekNext($.inArray(opts.radixPoint, getBuffer())) : $.inArray(opts.radixPoint, getBuffer())); else {
                     var clickPosition = selectedCaret.begin, lvclickPosition = getLastValidPosition(clickPosition), lastPosition = seekNext(lvclickPosition);
                     lastPosition > clickPosition ? caret(input, isMask(clickPosition) || isMask(clickPosition - 1) ? clickPosition : seekNext(clickPosition)) : ((getBuffer()[lastPosition] !== getPlaceholder(lastPosition) || !isMask(lastPosition, !0) && getTest(lastPosition).def === getPlaceholder(lastPosition)) && (lastPosition = seekNext(lastPosition)), 
                     caret(input, lastPosition));

File diff suppressed because it is too large
+ 347 - 4
dist/inputmask/inputmask.numeric.extensions.js


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

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

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !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);

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

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !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);

File diff suppressed because it is too large
+ 359 - 11
dist/jquery.inputmask.bundle.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.date.extensions.min.js


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

@@ -3,6 +3,6 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.2.6-24
+* Version: 3.2.6-25
 */
 !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});

File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.extensions.min.js


File diff suppressed because it is too large
+ 3 - 3
dist/min/inputmask/inputmask.min.js


File diff suppressed because it is too large
+ 2 - 2
dist/min/inputmask/inputmask.numeric.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.phone.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/inputmask.regex.extensions.min.js


File diff suppressed because it is too large
+ 1 - 1
dist/min/inputmask/jquery.inputmask.min.js


File diff suppressed because it is too large
+ 4 - 4
dist/min/jquery.inputmask.bundle.min.js


+ 20 - 10
js/inputmask.js

@@ -117,7 +117,7 @@
 				canClearPosition: $.noop, //hook to alter the clear behavior in the stripValidPositions args => maskset, position, lastValidPosition, opts => return true|false
 				postValidation: null, //hook to postValidate the result from isValid.	Usefull for validating the entry as a whole.	args => buffer, opts => return true/false
 				staticDefinitionSymbol: undefined, //specify a definitionSymbol for static content, used to make matches for alternators
-				jitMasking: false, //just in time masking ~ only mask while typing
+				jitMasking: false, //just in time masking ~ only mask while typing, can n (number), true or false
 			},
 			masksCache: {},
 			mask: function(elems) {
@@ -771,7 +771,7 @@
 						testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
 						test = testPos.match;
 						ndxIntlzr = testPos.locator.slice();
-						if (opts.jitMasking !== true || pos < lvp) {
+						if (opts.jitMasking === false || pos < lvp || (isFinite(opts.jitMasking) && opts.jitMasking > pos)) {
 							maskTemplate.push(getPlaceholder(pos, test));
 						}
 					}
@@ -975,10 +975,23 @@
 					ndxInitializer = ndxIntlzr || [0],
 					matches = [],
 					insertStop = false,
-					latestMatch, isFirstMatch;
+					latestMatch;
 
 				function resolveTestFromToken(maskToken, ndxInitializer, loopNdx, quantifierRecurse) { //ndxInitializer contains a set of indexes to speedup searches in the mtokens
 					function handleMatch(match, loopNdx, quantifierRecurse) {
+						function isFirstMatch(latestMatch, tokenGroup) {
+							var firstMatch = $.inArray(latestMatch, tokenGroup.matches) === 0;
+							if (!firstMatch) {
+								$.each(tokenGroup.matches, function(ndx, match) {
+									if (match.isQuantifier === true) {
+										firstMatch = isFirstMatch(latestMatch, tokenGroup.matches[ndx - 1]);
+										if (firstMatch) return false;
+									}
+								});
+							}
+							return firstMatch;
+						}
+
 						function resolveNdxInitializer(pos, alternateNdx) {
 							var bestMatch = selectBestMatch(pos, alternateNdx);
 							return bestMatch ? bestMatch.locator.slice(bestMatch.alternation + 1) : [];
@@ -1001,8 +1014,7 @@
 								match = resolveTestFromToken(match, ndxInitializer, loopNdx, quantifierRecurse);
 								if (match) {
 									latestMatch = matches[matches.length - 1].match;
-									isFirstMatch = $.inArray(latestMatch, optionalToken.matches) === 0;
-									if (isFirstMatch) {
+									if (isFirstMatch(latestMatch, optionalToken)) {
 										insertStop = true; //insert a stop
 										testPos = pos; //match the position after the group
 									} else return true;
@@ -1117,9 +1129,7 @@
 										//get latest match
 										latestMatch = matches[matches.length - 1].match;
 										latestMatch.optionalQuantifier = qndx > (qt.quantifier.min - 1);
-										isFirstMatch = $.inArray(latestMatch, tokenGroup.matches) === 0;
-
-										if (isFirstMatch) { //search for next possible match
+										if (isFirstMatch(latestMatch, tokenGroup)) { //search for next possible match
 											if (qndx > (qt.quantifier.min - 1)) {
 												insertStop = true;
 												testPos = pos; //match the position after the group
@@ -2035,7 +2045,7 @@
 						var $input = $(this),
 							input = this,
 							value = input.inputmask._valueGet();
-						if (value !== "" && value !== getBuffer().join("")) {
+						if (value !== getBuffer().join("") && getLastValidPosition() > 0) {
 							$input.trigger("setvalue");
 						}
 					});
@@ -2506,7 +2516,7 @@
 					var selectedCaret = caret(input);
 					if (selectedCaret.begin === selectedCaret.end) {
 						if (doRadixFocus(selectedCaret.begin)) {
-							caret(input, $.inArray(opts.radixPoint, getBuffer()));
+							caret(input, opts.numericInput ? seekNext($.inArray(opts.radixPoint, getBuffer())) : $.inArray(opts.radixPoint, getBuffer()));
 						} else {
 							var clickPosition = selectedCaret.begin,
 								lvclickPosition = getLastValidPosition(clickPosition),

+ 599 - 7
js/inputmask.numeric.extensions.js

@@ -19,6 +19,605 @@ Optional extensions on the jquery.inputmask base
 	(function($, Inputmask) {
 		//number aliases
 		Inputmask.extendAliases({
+			"numeric2": {
+				mask: function(opts) {
+					function autoEscape(txt) {
+						var escapedTxt = "";
+						for (var i = 0; i < txt.length; i++) {
+							escapedTxt += opts.definitions[txt.charAt(i)] ? "\\" + txt.charAt(i) : txt.charAt(i);
+						}
+						return escapedTxt;
+					}
+					if (opts.repeat !== 0 && isNaN(opts.integerDigits)) {
+						opts.integerDigits = opts.repeat;
+					}
+					opts.repeat = 0;
+					if (opts.groupSeparator === opts.radixPoint) { //treat equal separator and radixpoint
+						if (opts.radixPoint === ".") {
+							opts.groupSeparator = ",";
+						} else if (opts.radixPoint === ",") {
+							opts.groupSeparator = ".";
+						} else opts.groupSeparator = "";
+					}
+					if (opts.groupSeparator === " ") { //prevent conflict with default skipOptionalPartCharacter
+						opts.skipOptionalPartCharacter = undefined;
+					}
+					opts.autoGroup = opts.autoGroup && opts.groupSeparator !== "";
+					var seps = "+",
+						mod = 0;
+					if (opts.autoGroup) {
+						if (typeof opts.groupSize == "string" && isFinite(opts.groupSize)) opts.groupSize = parseInt(opts.groupSize);
+						if (isFinite(opts.integerDigits)) {
+							seps = Math.floor(opts.integerDigits / opts.groupSize);
+							mod = opts.integerDigits % opts.groupSize;
+						}
+					}
+
+					//enforce placeholder to single
+					if (opts.placeholder.length > 1) {
+						opts.placeholder = opts.placeholder.charAt(0);
+					}
+					if (opts.jitMasking === true && opts.placeholder.length > 0) {
+						opts.jitMasking = 1;
+					}
+
+					//only allow radixfocus when placeholder = 0
+					opts.radixFocus = opts.radixFocus && opts.placeholder !== "" && opts.integerOptional === true;
+
+					opts.definitions[";"] = opts.definitions["~"]; //clone integer def for decimals
+					opts.definitions[";"].definitionSymbol = "~";
+
+					var mask = autoEscape(opts.prefix);
+					mask += "[+]";
+					if (opts.autoGroup) {
+						mask += "(" + opts.groupSeparator + "~{" + opts.groupSize + "}){" + seps + "}";
+						if (mod > 0) mask += "~{" + mod + "}";
+					} else {
+						mask += "~{" + opts.integerDigits + "}";
+					}
+
+					if (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0)) {
+						if (opts.digitsOptional) {
+							mask += "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{1," + opts.digits + "}]";
+						} else {
+							mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}";
+							if (isFinite(opts.jitMasking)) {
+								if (opts.jitMasking < (1 + opts.radixPoint.length + (isFinite(opts.digits) ? opts.digits : 2))) {
+									opts.jitMasking = (1 + opts.radixPoint.length + (isFinite(opts.digits) ? opts.digits : 2));
+								}
+							}
+						}
+					}
+					if (opts.negationSymbol.back !== "") {
+						mask += "[-]";
+					}
+					mask += autoEscape(opts.suffix);
+
+					opts.greedy = false; //enforce greedy false
+
+					return mask;
+				},
+				placeholder: "",
+				greedy: false,
+				digits: "*", //number of fractionalDigits
+				digitsOptional: true,
+				radixPoint: ".",
+				radixFocus: true,
+				groupSize: 3,
+				groupSeparator: "",
+				autoGroup: false,
+				allowPlus: true,
+				allowMinus: true,
+				negationSymbol: {
+					front: "-", //"("
+					back: "" //")"
+				},
+				integerDigits: "+", //number of integerDigits
+				integerOptional: true,
+				prefix: "",
+				suffix: "",
+				rightAlign: true,
+				decimalProtect: true, //do not allow assumption of decimals input without entering the radixpoint
+				min: null, //minimum value
+				max: null, //maximum value
+				step: 1,
+				insertMode: true,
+				autoUnmask: false,
+				unmaskAsNumber: false,
+				jitMasking: true,
+				numericInput: true,
+				onBeforeWrite: function(e, buffer, caretPos, opts) {
+					if (e && (e.type === "blur" || e.type === "checkval")) {
+						//handle minvalue
+						var maskedValue = buffer.join(""),
+							processValue = maskedValue.replace(opts.prefix, "");
+						processValue = processValue.replace(opts.suffix, "");
+						processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
+						if (opts.radixPoint === ",") processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
+
+						if (isFinite(processValue)) {
+							if (isFinite(opts.min) && parseFloat(processValue) < parseFloat(opts.min)) {
+								return {
+									"refreshFromBuffer": true,
+									"buffer": (opts.prefix + opts.min).split("")
+								};
+							}
+						}
+						if (opts.numericInput !== true) {
+							var tmpBufSplit = opts.radixPoint !== "" ? buffer.join("").split(opts.radixPoint) : [buffer.join("")],
+								matchRslt = tmpBufSplit[0].match(opts.regex.integerPart(opts)),
+								matchRsltDigits = tmpBufSplit.length === 2 ? tmpBufSplit[1].match(opts.regex.integerNPart(opts)) : undefined;
+							if (matchRslt) {
+								if ((matchRslt[0] === opts.negationSymbol.front + "0" || matchRslt[0] === opts.negationSymbol.front || matchRslt[0] === "+") && (matchRsltDigits === undefined || matchRsltDigits[0].match(/^0+$/))) {
+									buffer.splice(matchRslt.index, 1);
+								}
+								var radixPosition = $.inArray(opts.radixPoint, buffer);
+								if (radixPosition !== -1) {
+									if (isFinite(opts.digits) && !opts.digitsOptional) {
+										for (var i = 1; i <= opts.digits; i++) {
+											if (buffer[radixPosition + i] === undefined || buffer[radixPosition + i] === opts.placeholder.charAt(0)) {
+												buffer[radixPosition + i] = "0";
+											}
+										}
+										return {
+											"refreshFromBuffer": maskedValue !== buffer.join(""),
+											"buffer": buffer
+										};
+									} else if (radixPosition === buffer.length - opts.suffix.length - 1) {
+										buffer.splice(radixPosition, 1);
+										return {
+											"refreshFromBuffer": true,
+											"buffer": buffer
+										};
+									}
+								}
+							}
+						}
+					}
+
+				},
+				regex: {
+					integerPart: function(opts) {
+						return new RegExp("[" + Inputmask.escapeRegex(opts.negationSymbol.front) + "\+]?\\d+");
+					},
+					integerNPart: function(opts) {
+						return new RegExp("[\\d" + Inputmask.escapeRegex(opts.groupSeparator) + "]+");
+					}
+				},
+				signHandler: function(chrs, maskset, pos, strict, opts) {
+					if (!strict && (opts.allowMinus && chrs === "-") || (opts.allowPlus && chrs === "+")) {
+						var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
+
+						if (matchRslt && matchRslt[0].length > 0) {
+							if (maskset.buffer[matchRslt.index] === (chrs === "-" ? "+" : opts.negationSymbol.front)) {
+								if (chrs === "-") {
+									if (opts.negationSymbol.back !== "") {
+										return {
+											"pos": matchRslt.index,
+											"c": opts.negationSymbol.front,
+											"remove": matchRslt.index,
+											"caret": pos,
+											"insert": {
+												"pos": maskset.buffer.length - opts.suffix.length - 1,
+												"c": opts.negationSymbol.back
+											}
+										};
+									} else {
+										return {
+											"pos": matchRslt.index,
+											"c": opts.negationSymbol.front,
+											"remove": matchRslt.index,
+											"caret": pos
+										};
+									}
+								} else {
+									if (opts.negationSymbol.back !== "") {
+										return {
+											"pos": matchRslt.index,
+											"c": "+",
+											"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
+											"caret": pos
+										};
+									} else {
+										return {
+											"pos": matchRslt.index,
+											"c": "+",
+											"remove": matchRslt.index,
+											"caret": pos
+										};
+									}
+								}
+							} else if (maskset.buffer[matchRslt.index] === (chrs === "-" ? opts.negationSymbol.front : "+")) {
+								if (chrs === "-" && opts.negationSymbol.back !== "") {
+									return {
+										"remove": [matchRslt.index, maskset.buffer.length - opts.suffix.length - 1],
+										"caret": pos - 1
+									};
+								} else {
+									return {
+										"remove": matchRslt.index,
+										"caret": pos - 1
+									};
+								}
+							} else {
+								if (chrs === "-") {
+									if (opts.negationSymbol.back !== "") {
+										return {
+											"pos": matchRslt.index,
+											"c": opts.negationSymbol.front,
+											"caret": pos + 1,
+											"insert": {
+												"pos": maskset.buffer.length - opts.suffix.length,
+												"c": opts.negationSymbol.back
+											}
+										};
+									} else {
+										return {
+											"pos": matchRslt.index,
+											"c": opts.negationSymbol.front,
+											"caret": pos + 1
+										};
+									}
+								} else {
+									return {
+										"pos": matchRslt.index,
+										"c": chrs,
+										"caret": pos + 1
+									};
+								}
+							}
+						}
+					}
+					return false;
+				},
+				radixHandler: function(chrs, maskset, pos, strict, opts) {
+					if (!strict) {
+						if ($.inArray(chrs, [",", "."]) !== -1) chrs = opts.radixPoint;
+						if (chrs === opts.radixPoint && (opts.digits !== undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))) {
+							var radixPos = $.inArray(opts.radixPoint, maskset.buffer),
+								integerValue = (opts.numericInput ? maskset.buffer.slice().reverse() : maskset.buffer).join("").match(opts.regex.integerPart(opts));
+
+							if (radixPos !== -1 && maskset.validPositions[radixPos]) {
+								if (maskset.validPositions[radixPos - 1]) {
+									return {
+										"caret": radixPos + 1
+									};
+								} else {
+									return {
+										"pos": integerValue.index,
+										c: integerValue[0],
+										"caret": radixPos + 1
+									};
+								}
+							} else if (!integerValue || (integerValue["0"] === "0" && (integerValue.index + 1) !== pos)) {
+								maskset.buffer[integerValue ? integerValue.index : pos] = "0";
+								return {
+									"pos": (integerValue ? integerValue.index : pos) + 1,
+									c: opts.radixPoint
+								};
+							}
+						}
+					}
+					return false;
+				},
+				leadingZeroHandler: function(chrs, maskset, pos, strict, opts) {
+					if (opts.numericInput === true) {
+						if (maskset.buffer[maskset.buffer.length - opts.prefix.length - 1] === "0") {
+							return {
+								"pos": pos,
+								"remove": maskset.buffer.length - opts.prefix.length - 1
+							};
+						}
+					} else {
+						var matchRslt = maskset.buffer.join("").match(opts.regex.integerNPart(opts)),
+							radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
+						if (matchRslt && !strict && (radixPosition === -1 || pos <= radixPosition)) {
+							if (matchRslt["0"].indexOf("0") === 0) {
+								if (pos < opts.prefix.length) pos = matchRslt.index; //position
+								var _radixPosition = $.inArray(opts.radixPoint, maskset._buffer);
+								var digitsMatch = maskset._buffer && maskset.buffer.slice(radixPosition).join("") === maskset._buffer.slice(_radixPosition).join("") || parseInt(maskset.buffer.slice(radixPosition + 1).join("")) === 0;
+								var integerMatch = maskset._buffer && maskset.buffer.slice(matchRslt.index, radixPosition).join("") === maskset._buffer.slice(opts.prefix.length, _radixPosition).join("") || maskset.buffer.slice(matchRslt.index, radixPosition).join("") === "0";
+
+								if (radixPosition === -1 || digitsMatch && integerMatch) {
+									maskset.buffer.splice(matchRslt.index, 1);
+									pos = pos > matchRslt.index ? pos - 1 : matchRslt.index;
+									return {
+										"pos": pos,
+										"remove": matchRslt.index
+									};
+								} else if (matchRslt.index + 1 === pos || chrs === "0") {
+									maskset.buffer.splice(matchRslt.index, 1);
+									pos = matchRslt.index;
+									return {
+										"pos": pos,
+										"remove": matchRslt.index
+									};
+								}
+							} else if (chrs === "0" && pos <= matchRslt.index && matchRslt["0"] !== opts.groupSeparator) {
+								return false;
+							}
+						}
+					}
+					return true;
+				},
+				postValidation: function(buffer, opts) {
+					//handle maxvalue
+					var isValid = true,
+						maskedValue = buffer.join(""),
+						processValue = maskedValue.replace(opts.prefix, "");
+					processValue = processValue.replace(opts.suffix, "");
+					processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
+					if (opts.radixPoint === ",") processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
+					//handle negation symbol
+					processValue = processValue.replace(new RegExp("^" + Inputmask.escapeRegex(opts.negationSymbol.front)), "-");
+					processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.negationSymbol.back) + "$"), "");
+					processValue = processValue === opts.negationSymbol.front ? processValue + "0" : processValue;
+
+					if (isFinite(processValue)) {
+						if (opts.max !== null && isFinite(opts.max)) {
+							isValid = parseFloat(processValue) <= parseFloat(opts.max);
+						}
+						if (isValid && opts.min !== null && isFinite(opts.min) && (processValue <= 0 || processValue.toString().length >= opts.min.toString().length)) {
+							isValid = parseFloat(processValue) >= parseFloat(opts.min);
+							if (!isValid) {
+								isValid = {
+									"refreshFromBuffer": true,
+									"buffer": (opts.prefix + opts.min).split("")
+								};
+							}
+						}
+					}
+
+					return isValid;
+				},
+				definitions: {
+					"~": {
+						validator: function(chrs, maskset, pos, strict, opts) {
+							var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
+							if (!isValid) {
+								isValid = opts.radixHandler(chrs, maskset, pos, strict, opts);
+								if (!isValid) {
+									isValid = strict ? new RegExp("[0-9" + Inputmask.escapeRegex(opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
+									if (isValid === true) {
+										isValid = opts.leadingZeroHandler(chrs, maskset, pos, strict, opts);
+										if (isValid === true) {
+											//handle overwrite when fixed precision
+											var radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
+											if (radixPosition !== -1 && opts.digitsOptional === false && opts.numericInput !== true && pos > radixPosition && !strict) {
+												isValid = {
+													"pos": pos,
+													"remove": pos
+												};
+											} else {
+												isValid = {
+													pos: pos
+												};
+											}
+										}
+									}
+								}
+							}
+
+							return isValid;
+						},
+						cardinality: 1,
+						prevalidator: null
+					},
+					"+": {
+						validator: function(chrs, maskset, pos, strict, opts) {
+							var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
+							if (!isValid && ((strict && opts.allowMinus && chrs === opts.negationSymbol.front) || (opts.allowMinus && chrs === "-") || (opts.allowPlus && chrs === "+"))) {
+								if (chrs === "-") {
+									if (opts.negationSymbol.back !== "") {
+										isValid = {
+											"pos": pos,
+											"c": chrs === "-" ? opts.negationSymbol.front : "+",
+											"caret": pos + 1,
+											"insert": {
+												"pos": maskset.buffer.length,
+												"c": opts.negationSymbol.back
+											}
+										};
+									} else {
+										isValid = {
+											"pos": pos,
+											"c": chrs === "-" ? opts.negationSymbol.front : "+",
+											"caret": pos + 1
+										};
+									}
+								} else {
+									isValid = true;
+								}
+							}
+							return isValid;
+						},
+						cardinality: 1,
+						prevalidator: null,
+						placeholder: ""
+					},
+					"-": {
+						validator: function(chrs, maskset, pos, strict, opts) {
+							var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
+							if (!isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back) {
+								isValid = true;
+							}
+							return isValid;
+						},
+						cardinality: 1,
+						prevalidator: null,
+						placeholder: ""
+					},
+					":": {
+						validator: function(chrs, maskset, pos, strict, opts) {
+							var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
+							if (!isValid) {
+								var radix = "[" + Inputmask.escapeRegex(opts.radixPoint) + ",\\." + "]";
+								isValid = new RegExp(radix).test(chrs);
+								if (isValid && maskset.validPositions[pos] && maskset.validPositions[pos].match.placeholder === opts.radixPoint) {
+									isValid = {
+										"caret": pos + 1
+									};
+								}
+							}
+							return isValid ? {
+								c: opts.radixPoint
+							} : isValid;
+						},
+						cardinality: 1,
+						prevalidator: null,
+						placeholder: function(opts) {
+							return opts.radixPoint;
+						}
+					}
+				},
+				onUnMask: function(maskedValue, unmaskedValue, opts) {
+					var processValue = maskedValue.replace(opts.prefix, "");
+					processValue = processValue.replace(opts.suffix, "");
+					processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
+					if (opts.unmaskAsNumber) {
+						if (opts.radixPoint !== "" && processValue.indexOf(opts.radixPoint) !== -1) processValue = processValue.replace(Inputmask.escapeRegex.call(this, opts.radixPoint), ".");
+						return Number(processValue);
+					}
+					return processValue;
+				},
+				isComplete: function(buffer, opts) {
+					var maskedValue = buffer.join("");
+
+					var processValue = maskedValue.replace(opts.prefix, "");
+					processValue = processValue.replace(opts.suffix, "");
+					processValue = processValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
+					if (opts.radixPoint === ",") processValue = processValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
+					return isFinite(processValue);
+				},
+				onBeforeMask: function(initialValue, opts) {
+					if (opts.radixPoint !== "" && isFinite(initialValue)) {
+						initialValue = initialValue.toString().replace(".", opts.radixPoint);
+					} else {
+						var kommaMatches = initialValue.match(/,/g);
+						var dotMatches = initialValue.match(/\./g);
+						if (dotMatches && kommaMatches) {
+							if (dotMatches.length > kommaMatches.length) {
+								initialValue = initialValue.replace(/\./g, "");
+								initialValue = initialValue.replace(",", opts.radixPoint);
+							} else if (kommaMatches.length > dotMatches.length) {
+								initialValue = initialValue.replace(/,/g, "");
+								initialValue = initialValue.replace(".", opts.radixPoint);
+							} else { //equal
+								initialValue = initialValue.indexOf(".") < initialValue.indexOf(",") ? initialValue.replace(/\./g, "") : initialValue = initialValue.replace(/,/g, "");
+							}
+						} else {
+							initialValue = initialValue.replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "");
+						}
+					}
+
+					if (opts.digits === 0) {
+						if (initialValue.indexOf(".") !== -1) {
+							initialValue = initialValue.substring(0, initialValue.indexOf("."));
+						} else if (initialValue.indexOf(",") !== -1) {
+							initialValue = initialValue.substring(0, initialValue.indexOf(","));
+						}
+					}
+
+					if (opts.radixPoint !== "" && isFinite(opts.digits) && initialValue.indexOf(opts.radixPoint) !== -1) {
+						var valueParts = initialValue.split(opts.radixPoint),
+							decPart = valueParts[1].match(new RegExp("\\d*"))[0];
+						if (parseInt(opts.digits) < decPart.toString().length) {
+							var digitsFactor = Math.pow(10, parseInt(opts.digits));
+							//make the initialValue a valid javascript number for the parsefloat
+							initialValue = initialValue.replace(Inputmask.escapeRegex(opts.radixPoint), ".");
+							initialValue = Math.round(parseFloat(initialValue) * digitsFactor) / digitsFactor;
+							initialValue = initialValue.toString().replace(".", opts.radixPoint);
+						}
+					}
+					return initialValue.toString();
+				},
+				canClearPosition: function(maskset, position, lvp, strict, opts) {
+					var positionInput = maskset.validPositions[position].input,
+						canClear = ((positionInput !== opts.radixPoint || (maskset.validPositions[position].match.fn !== null && opts.decimalProtect === false)) || isFinite(positionInput)) ||
+						position === lvp ||
+						positionInput === opts.groupSeparator ||
+						positionInput === opts.negationSymbol.front ||
+						positionInput === opts.negationSymbol.back;
+
+					if (canClear && isFinite(positionInput)) {
+						var matchRslt,
+							radixPos = $.inArray(opts.radixPoint, maskset.buffer);
+
+						//inject radixpoint
+						var radixInjection = false;
+						if (maskset.validPositions[radixPos] === undefined) {
+							maskset.validPositions[radixPos] = {
+								input: opts.radixPoint
+							};
+							radixInjection = true;
+						}
+
+						if (!strict && maskset.buffer) {
+							matchRslt = maskset.buffer.join("").substr(0, position).match(opts.regex.integerNPart(opts));
+							var pos = position + 1,
+								isNull = matchRslt == null || parseInt(matchRslt["0"].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")) === 0;
+							if (isNull) {
+								while (maskset.validPositions[pos] && (maskset.validPositions[pos].input === opts.groupSeparator || maskset.validPositions[pos].input === "0")) {
+									delete maskset.validPositions[pos];
+									pos++;
+								}
+							}
+						}
+
+						var buffer = [];
+						//build new buffer from validPositions
+						for (var vp in maskset.validPositions) {
+							if (maskset.validPositions[vp].input !== undefined) buffer.push(maskset.validPositions[vp].input);
+						}
+						//remove radix Injection
+						if (radixInjection) {
+							delete maskset.validPositions[radixPos];
+						}
+
+						if (radixPos > 0) {
+							var bufVal = buffer.join("");
+							matchRslt = bufVal.match(opts.regex.integerNPart(opts));
+							if (matchRslt) {
+								if (position <= radixPos) {
+									if (matchRslt["0"].indexOf("0") === 0) {
+										canClear = matchRslt.index !== position || opts.placeholder === "0";
+									} else {
+										var intPart = parseInt(matchRslt["0"].replace(new RegExp(Inputmask.escapeRegex(opts.groupSeparator), "g"), "")),
+											radixPart = parseInt(bufVal.split(opts.radixPoint)[1]);
+										if (intPart < 10 && maskset.validPositions[position] && (opts.placeholder !== "0" || radixPart > 0)) {
+											maskset.validPositions[position].input = "0";
+											maskset.p = opts.prefix.length + 1;
+											canClear = false;
+										}
+									}
+								} else if (matchRslt["0"].indexOf("0") === 0) {
+									if (bufVal.length === 3) {
+										maskset.validPositions = {};
+										canClear = false;
+									}
+								}
+							}
+						}
+					}
+
+					return canClear;
+				},
+				onKeyDown: function(e, buffer, caretPos, opts) {
+					var $input = $(this);
+					if (e.ctrlKey) {
+						switch (e.keyCode) {
+							case Inputmask.keyCode.UP:
+								$input.val(parseFloat(this.inputmask.unmaskedvalue()) + parseInt(opts.step));
+								$input.trigger("setvalue");
+								break;
+							case Inputmask.keyCode.DOWN:
+								$input.val(parseFloat(this.inputmask.unmaskedvalue()) - parseInt(opts.step));
+								$input.trigger("setvalue");
+								break;
+						}
+					}
+				}
+			},
 			"numeric": {
 				mask: function(opts) {
 					function autoEscape(txt) {
@@ -65,13 +664,6 @@ Optional extensions on the jquery.inputmask base
 					opts.definitions[";"] = opts.definitions["~"]; //clone integer def for decimals
 					opts.definitions[";"].definitionSymbol = "~";
 
-					if (opts.numericInput === true) { //finance people input style
-						opts.radixFocus = false;
-						opts.digitsOptional = false;
-						if (isNaN(opts.digits)) opts.digits = 2;
-						opts.decimalProtect = false;
-					}
-
 					var mask = autoEscape(opts.prefix);
 					mask += "[+]";
 					if (opts.integerOptional === true) {

+ 1 - 1
package.json

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