浏览代码

handle -+

Robin Herbots 11 年之前
父节点
当前提交
e1e62553cf
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      js/jquery.inputmask.numeric.extensions.js

+ 4 - 4
js/jquery.inputmask.numeric.extensions.js

@@ -138,7 +138,7 @@ Optional extensions on the jquery.inputmask base
 
                 if (!needsRefresh && suffixStripped) {
                     for (var i = 0, l = opts.suffix.length; i < l; i++) {
-                        buffer[buffer.length + i] = opts.suffix.charAt(i);
+                        buffer.push(opts.suffix.charAt(i));
                     }
                 }
                 return { pos: newPos, "refreshFromBuffer": needsRefresh, "buffer": buffer };
@@ -161,7 +161,7 @@ Optional extensions on the jquery.inputmask base
                     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 && matchRslt[0] == "-0" && (matchRsltDigits == undefined || matchRsltDigits[0].match(/^0+$/))) {
+                    if (matchRslt && (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);
@@ -180,7 +180,7 @@ Optional extensions on the jquery.inputmask base
                 }
             },
             regex: {
-                integerPart: function (opts) { return new RegExp('[' + opts.negationSymbol.front + '\+]?\\d+'); },
+                integerPart: function (opts) { return new RegExp('[' + $.inputmask.escapeRegex.call(this, opts.negationSymbol.front) + '\+]?\\d*'); },
                 integerNPart: function (opts) { return new RegExp('[\\d' + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + ']+'); }
             },
             signHandler: function (chrs, maskset, pos, strict, opts) {
@@ -232,7 +232,7 @@ Optional extensions on the jquery.inputmask base
                             pos = matchRslt.index;
                             return { "pos": pos, "remove": matchRslt.index };
                         }
-                    } else if (chrs === "0" && pos <= matchRslt.index) {
+                    } else if (chrs === "0" && pos <= matchRslt.index && matchRslt["0"] != opts.groupSeparator) {
                         return false;
                     }
                 }