浏览代码

fix for FilipeZhou decimal 10101

Robin Herbots 11 年之前
父节点
当前提交
57b28aabdc

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

@@ -499,7 +499,7 @@
             }), $.isFunction(opts.postValidation) && 0 != result && !strict) {
             }), $.isFunction(opts.postValidation) && 0 != result && !strict) {
                 resetMaskSet(!0);
                 resetMaskSet(!0);
                 var postValidResult = opts.postValidation(getBuffer(), opts);
                 var postValidResult = opts.postValidation(getBuffer(), opts);
-                if (!postValidResult) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone), 
+                if (!postValidResult) return resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone), 
                 !1;
                 !1;
             }
             }
             return result;
             return result;

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.min.js


+ 31 - 13
dist/inputmask/jquery.inputmask.numeric.extensions.js

@@ -26,7 +26,7 @@
                 opts.radixFocus = opts.radixFocus && "0" == opts.placeholder, opts.definitions[";"] = opts.definitions["~"];
                 opts.radixFocus = opts.radixFocus && "0" == opts.placeholder, opts.definitions[";"] = opts.definitions["~"];
                 var mask = autoEscape(opts.prefix);
                 var mask = autoEscape(opts.prefix);
                 return mask += "[+]", mask += "~{1," + opts.integerDigits + "}", void 0 != opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"), 
                 return mask += "[+]", mask += "~{1," + opts.integerDigits + "}", void 0 != opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"), 
-                mask += autoEscape(opts.suffix), opts.greedy = !1, mask;
+                mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, mask;
             },
             },
             placeholder: "",
             placeholder: "",
             greedy: !1,
             greedy: !1,
@@ -39,6 +39,10 @@
             autoGroup: !1,
             autoGroup: !1,
             allowPlus: !0,
             allowPlus: !0,
             allowMinus: !0,
             allowMinus: !0,
+            negationSymbol: {
+                front: "-",
+                back: ""
+            },
             integerDigits: "+",
             integerDigits: "+",
             prefix: "",
             prefix: "",
             suffix: "",
             suffix: "",
@@ -96,27 +100,27 @@
                 }
                 }
             },
             },
             regex: {
             regex: {
-                integerPart: function() {
-                    return new RegExp("[-+]?\\d+");
+                integerPart: function(opts) {
+                    return new RegExp("[" + opts.negationSymbol.front + "+]?\\d+");
                 },
                 },
                 integerNPart: function(opts) {
                 integerNPart: function(opts) {
                     return new RegExp("[\\d" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]+");
                     return new RegExp("[\\d" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]+");
                 }
                 }
             },
             },
             signHandler: function(chrs, maskset, pos, strict, opts) {
             signHandler: function(chrs, maskset, pos, strict, opts) {
-                if (!strict && (opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs)) {
+                if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
-                    if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
+                    if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : opts.negationSymbol.front) ? {
                         pos: matchRslt.index,
                         pos: matchRslt.index,
-                        c: chrs,
+                        c: "-" === chrs ? opts.negationSymbol.front : "+",
                         remove: matchRslt.index,
                         remove: matchRslt.index,
                         caret: pos
                         caret: pos
-                    } : maskset.buffer[matchRslt.index] == ("-" === chrs ? "-" : "+") ? {
+                    } : maskset.buffer[matchRslt.index] == ("-" === chrs ? opts.negationSymbol.front : "+") ? {
                         remove: matchRslt.index,
                         remove: matchRslt.index,
                         caret: pos - 1
                         caret: pos - 1
                     } : {
                     } : {
                         pos: matchRslt.index,
                         pos: matchRslt.index,
-                        c: chrs,
+                        c: "-" === chrs ? opts.negationSymbol.front : "+",
                         caret: pos + 1
                         caret: pos + 1
                     };
                     };
                 }
                 }
@@ -188,7 +192,17 @@
                 "+": {
                 "+": {
                     validator: function(chrs, maskset, pos, strict, opts) {
                     validator: function(chrs, maskset, pos, strict, opts) {
                         var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
                         var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
-                        return isValid || (isValid = opts.allowMinus && "-" == chrs || opts.allowPlus && "+" == chrs), 
+                        return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && "-" == chrs || opts.allowPlus && "+" == chrs) && (isValid = !0), 
+                        isValid;
+                    },
+                    cardinality: 1,
+                    prevalidator: null,
+                    placeholder: ""
+                },
+                "-": {
+                    validator: function(chrs, maskset, pos, strict, opts) {
+                        var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
+                        return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0), 
                         isValid;
                         isValid;
                     },
                     },
                     cardinality: 1,
                     cardinality: 1,
@@ -240,12 +254,16 @@
             canClearPosition: function(maskset, position, lvp, strict, opts) {
             canClearPosition: function(maskset, position, lvp, strict, opts) {
                 var positionInput = maskset.validPositions[position].input, canClear = positionInput != opts.radixPoint && isFinite(positionInput) || position == lvp || positionInput == opts.groupSeparator;
                 var positionInput = maskset.validPositions[position].input, canClear = positionInput != opts.radixPoint && isFinite(positionInput) || position == lvp || positionInput == opts.groupSeparator;
                 if (canClear && isFinite(positionInput)) {
                 if (canClear && isFinite(positionInput)) {
-                    if (!strict) for (var pos = position + 1; maskset.validPositions[pos] && (maskset.validPositions[pos].input == opts.groupSeparator || "0" == maskset.validPositions[pos].input); ) delete maskset.validPositions[pos], 
-                    pos++;
+                    var matchRslt = maskset.buffer.join("").substr(0, position).match(opts.regex.integerNPart(opts));
+                    if (!strict) {
+                        var pos = position + 1, isNull = null == matchRslt || 0 == parseInt(matchRslt[0].replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""));
+                        if (isNull) for (;maskset.validPositions[pos] && (maskset.validPositions[pos].input == opts.groupSeparator || "0" == maskset.validPositions[pos].input); ) delete maskset.validPositions[pos], 
+                        pos++;
+                    }
                     var buffer = [];
                     var buffer = [];
                     for (var vp in maskset.validPositions) buffer.push(maskset.validPositions[vp].input);
                     for (var vp in maskset.validPositions) buffer.push(maskset.validPositions[vp].input);
-                    var matchRslt = buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                    if (matchRslt && (-1 == radixPosition || radixPosition >= position)) if (0 == matchRslt[0].indexOf("0")) canClear = matchRslt.index != position || -1 == radixPosition; else {
+                    if (matchRslt = buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer), 
+                    matchRslt && (-1 == radixPosition || position <= radixPosition)) if (0 == matchRslt[0].indexOf("0")) canClear = matchRslt.index != position || -1 == radixPosition; else {
                         var intPart = parseInt(matchRslt[0].replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""));
                         var intPart = parseInt(matchRslt[0].replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""));
                         -1 != radixPosition && 10 > intPart && "0" == opts.placeholder.charAt(0) && (maskset.validPositions[position].input = "0", 
                         -1 != radixPosition && 10 > intPart && "0" == opts.placeholder.charAt(0) && (maskset.validPositions[position].input = "0", 
                         maskset.p = opts.prefix.length + 1, canClear = !1);
                         maskset.p = opts.prefix.length + 1, canClear = !1);

文件差异内容过多而无法显示
+ 1 - 1
dist/inputmask/jquery.inputmask.numeric.extensions.min.js


+ 32 - 14
dist/jquery.inputmask.bundle.js

@@ -497,7 +497,7 @@
             }), $.isFunction(opts.postValidation) && 0 != result && !strict) {
             }), $.isFunction(opts.postValidation) && 0 != result && !strict) {
                 resetMaskSet(!0);
                 resetMaskSet(!0);
                 var postValidResult = opts.postValidation(getBuffer(), opts);
                 var postValidResult = opts.postValidation(getBuffer(), opts);
-                if (!postValidResult) return getMaskSet().validPositions = $.extend(!0, {}, positionsClone), 
+                if (!postValidResult) return resetMaskSet(!0), getMaskSet().validPositions = $.extend(!0, {}, positionsClone), 
                 !1;
                 !1;
             }
             }
             return result;
             return result;
@@ -1826,7 +1826,7 @@
                 opts.radixFocus = opts.radixFocus && "0" == opts.placeholder, opts.definitions[";"] = opts.definitions["~"];
                 opts.radixFocus = opts.radixFocus && "0" == opts.placeholder, opts.definitions[";"] = opts.definitions["~"];
                 var mask = autoEscape(opts.prefix);
                 var mask = autoEscape(opts.prefix);
                 return mask += "[+]", mask += "~{1," + opts.integerDigits + "}", void 0 != opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"), 
                 return mask += "[+]", mask += "~{1," + opts.integerDigits + "}", void 0 != opts.digits && (isNaN(opts.digits) || parseInt(opts.digits) > 0) && (mask += opts.digitsOptional ? "[" + (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}]" : (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}"), 
-                mask += autoEscape(opts.suffix), opts.greedy = !1, mask;
+                mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, mask;
             },
             },
             placeholder: "",
             placeholder: "",
             greedy: !1,
             greedy: !1,
@@ -1839,6 +1839,10 @@
             autoGroup: !1,
             autoGroup: !1,
             allowPlus: !0,
             allowPlus: !0,
             allowMinus: !0,
             allowMinus: !0,
+            negationSymbol: {
+                front: "-",
+                back: ""
+            },
             integerDigits: "+",
             integerDigits: "+",
             prefix: "",
             prefix: "",
             suffix: "",
             suffix: "",
@@ -1896,27 +1900,27 @@
                 }
                 }
             },
             },
             regex: {
             regex: {
-                integerPart: function() {
-                    return new RegExp("[-+]?\\d+");
+                integerPart: function(opts) {
+                    return new RegExp("[" + opts.negationSymbol.front + "+]?\\d+");
                 },
                 },
                 integerNPart: function(opts) {
                 integerNPart: function(opts) {
                     return new RegExp("[\\d" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]+");
                     return new RegExp("[\\d" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]+");
                 }
                 }
             },
             },
             signHandler: function(chrs, maskset, pos, strict, opts) {
             signHandler: function(chrs, maskset, pos, strict, opts) {
-                if (!strict && (opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs)) {
+                if (!strict && opts.allowMinus && "-" === chrs || opts.allowPlus && "+" === chrs) {
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
                     var matchRslt = maskset.buffer.join("").match(opts.regex.integerPart(opts));
-                    if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : "-") ? {
+                    if (matchRslt && matchRslt[0].length > 0) return maskset.buffer[matchRslt.index] == ("-" === chrs ? "+" : opts.negationSymbol.front) ? {
                         pos: matchRslt.index,
                         pos: matchRslt.index,
-                        c: chrs,
+                        c: "-" === chrs ? opts.negationSymbol.front : "+",
                         remove: matchRslt.index,
                         remove: matchRslt.index,
                         caret: pos
                         caret: pos
-                    } : maskset.buffer[matchRslt.index] == ("-" === chrs ? "-" : "+") ? {
+                    } : maskset.buffer[matchRslt.index] == ("-" === chrs ? opts.negationSymbol.front : "+") ? {
                         remove: matchRslt.index,
                         remove: matchRslt.index,
                         caret: pos - 1
                         caret: pos - 1
                     } : {
                     } : {
                         pos: matchRslt.index,
                         pos: matchRslt.index,
-                        c: chrs,
+                        c: "-" === chrs ? opts.negationSymbol.front : "+",
                         caret: pos + 1
                         caret: pos + 1
                     };
                     };
                 }
                 }
@@ -1988,7 +1992,17 @@
                 "+": {
                 "+": {
                     validator: function(chrs, maskset, pos, strict, opts) {
                     validator: function(chrs, maskset, pos, strict, opts) {
                         var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
                         var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
-                        return isValid || (isValid = opts.allowMinus && "-" == chrs || opts.allowPlus && "+" == chrs), 
+                        return !isValid && (strict && opts.allowMinus && chrs === opts.negationSymbol.front || opts.allowMinus && "-" == chrs || opts.allowPlus && "+" == chrs) && (isValid = !0), 
+                        isValid;
+                    },
+                    cardinality: 1,
+                    prevalidator: null,
+                    placeholder: ""
+                },
+                "-": {
+                    validator: function(chrs, maskset, pos, strict, opts) {
+                        var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
+                        return !isValid && strict && opts.allowMinus && chrs === opts.negationSymbol.back && (isValid = !0), 
                         isValid;
                         isValid;
                     },
                     },
                     cardinality: 1,
                     cardinality: 1,
@@ -2040,12 +2054,16 @@
             canClearPosition: function(maskset, position, lvp, strict, opts) {
             canClearPosition: function(maskset, position, lvp, strict, opts) {
                 var positionInput = maskset.validPositions[position].input, canClear = positionInput != opts.radixPoint && isFinite(positionInput) || position == lvp || positionInput == opts.groupSeparator;
                 var positionInput = maskset.validPositions[position].input, canClear = positionInput != opts.radixPoint && isFinite(positionInput) || position == lvp || positionInput == opts.groupSeparator;
                 if (canClear && isFinite(positionInput)) {
                 if (canClear && isFinite(positionInput)) {
-                    if (!strict) for (var pos = position + 1; maskset.validPositions[pos] && (maskset.validPositions[pos].input == opts.groupSeparator || "0" == maskset.validPositions[pos].input); ) delete maskset.validPositions[pos], 
-                    pos++;
+                    var matchRslt = maskset.buffer.join("").substr(0, position).match(opts.regex.integerNPart(opts));
+                    if (!strict) {
+                        var pos = position + 1, isNull = null == matchRslt || 0 == parseInt(matchRslt[0].replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""));
+                        if (isNull) for (;maskset.validPositions[pos] && (maskset.validPositions[pos].input == opts.groupSeparator || "0" == maskset.validPositions[pos].input); ) delete maskset.validPositions[pos], 
+                        pos++;
+                    }
                     var buffer = [];
                     var buffer = [];
                     for (var vp in maskset.validPositions) buffer.push(maskset.validPositions[vp].input);
                     for (var vp in maskset.validPositions) buffer.push(maskset.validPositions[vp].input);
-                    var matchRslt = buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
-                    if (matchRslt && (-1 == radixPosition || radixPosition >= position)) if (0 == matchRslt[0].indexOf("0")) canClear = matchRslt.index != position || -1 == radixPosition; else {
+                    if (matchRslt = buffer.join("").match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer), 
+                    matchRslt && (-1 == radixPosition || position <= radixPosition)) if (0 == matchRslt[0].indexOf("0")) canClear = matchRslt.index != position || -1 == radixPosition; else {
                         var intPart = parseInt(matchRslt[0].replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""));
                         var intPart = parseInt(matchRslt[0].replace(new RegExp($.inputmask.escapeRegex.call(this, opts.groupSeparator), "g"), ""));
                         -1 != radixPosition && 10 > intPart && "0" == opts.placeholder.charAt(0) && (maskset.validPositions[position].input = "0", 
                         -1 != radixPosition && 10 > intPart && "0" == opts.placeholder.charAt(0) && (maskset.validPositions[position].input = "0", 
                         maskset.p = opts.prefix.length + 1, canClear = !1);
                         maskset.p = opts.prefix.length + 1, canClear = !1);

文件差异内容过多而无法显示
+ 3 - 3
dist/jquery.inputmask.bundle.min.js


+ 1 - 0
js/jquery.inputmask.js

@@ -919,6 +919,7 @@
                     resetMaskSet(true);
                     resetMaskSet(true);
                     var postValidResult = opts.postValidation(getBuffer(), opts);
                     var postValidResult = opts.postValidation(getBuffer(), opts);
                     if (!postValidResult) {
                     if (!postValidResult) {
+                        resetMaskSet(true);
                         getMaskSet()["validPositions"] = $.extend(true, {}, positionsClone); //revert validation changes
                         getMaskSet()["validPositions"] = $.extend(true, {}, positionsClone); //revert validation changes
                         return false;
                         return false;
                     }
                     }

+ 33 - 13
js/jquery.inputmask.numeric.extensions.js

@@ -56,6 +56,7 @@ Optional extensions on the jquery.inputmask base
                     else mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}";
                     else mask += (opts.decimalProtect ? ":" : opts.radixPoint) + ";{" + opts.digits + "}";
                 }
                 }
                 mask += autoEscape(opts.suffix);
                 mask += autoEscape(opts.suffix);
+                mask += "[-]";
 
 
                 opts.greedy = false; //enforce greedy false
                 opts.greedy = false; //enforce greedy false
                 return mask;
                 return mask;
@@ -71,6 +72,10 @@ Optional extensions on the jquery.inputmask base
             autoGroup: false,
             autoGroup: false,
             allowPlus: true,
             allowPlus: true,
             allowMinus: true,
             allowMinus: true,
+            negationSymbol: {
+                front: "-", //"("
+                back: "" //")"
+            },
             integerDigits: "+", //number of integerDigits
             integerDigits: "+", //number of integerDigits
             prefix: "",
             prefix: "",
             suffix: "",
             suffix: "",
@@ -159,20 +164,20 @@ Optional extensions on the jquery.inputmask base
                 }
                 }
             },
             },
             regex: {
             regex: {
-                integerPart: function (opts) { return new RegExp('[-\+]?\\d+'); },
+                integerPart: function (opts) { return new RegExp('[' + opts.negationSymbol.front + '\+]?\\d+'); },
                 integerNPart: function (opts) { return new RegExp('[\\d' + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + ']+'); }
                 integerNPart: function (opts) { return new RegExp('[\\d' + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + ']+'); }
             },
             },
             signHandler: function (chrs, maskset, pos, strict, opts) {
             signHandler: function (chrs, maskset, pos, strict, opts) {
-                if (!strict && (opts.allowMinus && chrs === "-" || opts.allowPlus && chrs === "+")) {
+                if (!strict && (opts.allowMinus && chrs === "-") || (opts.allowPlus && chrs === "+")) {
                     var matchRslt = maskset.buffer.join('').match(opts.regex.integerPart(opts));
                     var matchRslt = maskset.buffer.join('').match(opts.regex.integerPart(opts));
 
 
                     if (matchRslt && matchRslt[0].length > 0) {
                     if (matchRslt && matchRslt[0].length > 0) {
-                        if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "+" : "-")) {
-                            return { "pos": matchRslt.index, "c": chrs, "remove": matchRslt.index, "caret": pos };
-                        } else if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "-" : "+")) {
+                        if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "+" : opts.negationSymbol.front)) {
+                            return { "pos": matchRslt.index, "c": chrs === "-" ? opts.negationSymbol.front : "+", "remove": matchRslt.index, "caret": pos };
+                        } else if (maskset.buffer[matchRslt.index] == (chrs === "-" ? opts.negationSymbol.front : "+")) {
                             return { "remove": matchRslt.index, "caret": pos - 1 };
                             return { "remove": matchRslt.index, "caret": pos - 1 };
                         } else {
                         } else {
-                            return { "pos": matchRslt.index, "c": chrs, "caret": pos + 1 };
+                            return { "pos": matchRslt.index, "c": chrs === "-" ? opts.negationSymbol.front : "+", "caret": pos + 1 };
                         }
                         }
                     }
                     }
                 }
                 }
@@ -263,8 +268,20 @@ Optional extensions on the jquery.inputmask base
                 '+': {
                 '+': {
                     validator: function (chrs, maskset, pos, strict, opts) {
                     validator: function (chrs, maskset, pos, strict, opts) {
                         var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
                         var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
-                        if (!isValid) {
-                            isValid = (opts.allowMinus && chrs == "-") || (opts.allowPlus && chrs == "+");
+                        if (!isValid && ((strict && opts.allowMinus && chrs === opts.negationSymbol.front) || (opts.allowMinus && chrs == "-") || (opts.allowPlus && chrs == "+"))) {
+                            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;
                         return isValid;
                     },
                     },
@@ -347,11 +364,14 @@ Optional extensions on the jquery.inputmask base
                     posOffset = 0;
                     posOffset = 0;
 
 
                 if (canClear && isFinite(positionInput)) {
                 if (canClear && isFinite(positionInput)) {
+                    var matchRslt = maskset["buffer"].join('').substr(0, position).match(opts.regex.integerNPart(opts));
                     if (!strict) {
                     if (!strict) {
-                        var pos = position + 1;
-                        while (maskset["validPositions"][pos] && (maskset["validPositions"][pos].input == opts.groupSeparator || maskset["validPositions"][pos].input == "0")) {
-                            delete maskset["validPositions"][pos];
-                            pos++;
+                        var pos = position + 1, isNull = matchRslt == null || parseInt(matchRslt["0"].replace(new RegExp($.inputmask.escapeRegex.call(this, 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++;
+                            }
                         }
                         }
                     }
                     }
 
 
@@ -360,7 +380,7 @@ Optional extensions on the jquery.inputmask base
                     for (var vp in maskset.validPositions) {
                     for (var vp in maskset.validPositions) {
                         buffer.push(maskset.validPositions[vp].input);
                         buffer.push(maskset.validPositions[vp].input);
                     }
                     }
-                    var matchRslt = buffer.join('').match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
+                    matchRslt = buffer.join('').match(opts.regex.integerNPart(opts)), radixPosition = $.inArray(opts.radixPoint, maskset.buffer);
                     if (matchRslt && (radixPosition == -1 || position <= radixPosition)) {
                     if (matchRslt && (radixPosition == -1 || position <= radixPosition)) {
                         if (matchRslt["0"].indexOf("0") == 0) {
                         if (matchRslt["0"].indexOf("0") == 0) {
                             canClear = matchRslt.index != position || radixPosition == -1;
                             canClear = matchRslt.index != position || radixPosition == -1;

+ 28 - 0
qunit/tests_numeric.js

@@ -1190,4 +1190,32 @@ asyncTest("currency alias - max 1000 - type 1234", function () {
         equal($("#testmask")[0]._valueGet(), "$ 123.00", "Result " + $("#testmask")[0]._valueGet());
         equal($("#testmask")[0]._valueGet(), "$ 123.00", "Result " + $("#testmask")[0]._valueGet());
         $("#testmask").remove();
         $("#testmask").remove();
     }, 5);
     }, 5);
+});
+
+test("currency alias - type 1010 delete first 1 - FilipeZhou", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("currency");
+
+    $("#testmask")[0].focus();
+    $("#testmask").click();
+    $("#testmask").Type("1010");
+    $.caret($("#testmask"), 3);
+    $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
+    equal($("#testmask")[0]._valueGet(), "$ 10.00", "Result " + $("#testmask")[0]._valueGet());
+    $("#testmask").remove();
+});
+
+test("currency alias - type 1010 delete middle 1 - FilipeZhou", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("currency");
+
+    $("#testmask")[0].focus();
+    $("#testmask").click();
+    $("#testmask").Type("1010");
+    $.caret($("#testmask"), 6);
+    $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
+    equal($("#testmask")[0]._valueGet(), "$ 100.00", "Result " + $("#testmask")[0]._valueGet());
+    $("#testmask").remove();
 });
 });