|
|
@@ -497,7 +497,7 @@
|
|
|
}), $.isFunction(opts.postValidation) && 0 != result && !strict) {
|
|
|
resetMaskSet(!0);
|
|
|
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;
|
|
|
}
|
|
|
return result;
|
|
|
@@ -1826,7 +1826,7 @@
|
|
|
opts.radixFocus = opts.radixFocus && "0" == opts.placeholder, opts.definitions[";"] = opts.definitions["~"];
|
|
|
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 + "}"),
|
|
|
- mask += autoEscape(opts.suffix), opts.greedy = !1, mask;
|
|
|
+ mask += autoEscape(opts.suffix), mask += "[-]", opts.greedy = !1, mask;
|
|
|
},
|
|
|
placeholder: "",
|
|
|
greedy: !1,
|
|
|
@@ -1839,6 +1839,10 @@
|
|
|
autoGroup: !1,
|
|
|
allowPlus: !0,
|
|
|
allowMinus: !0,
|
|
|
+ negationSymbol: {
|
|
|
+ front: "-",
|
|
|
+ back: ""
|
|
|
+ },
|
|
|
integerDigits: "+",
|
|
|
prefix: "",
|
|
|
suffix: "",
|
|
|
@@ -1896,27 +1900,27 @@
|
|
|
}
|
|
|
},
|
|
|
regex: {
|
|
|
- integerPart: function() {
|
|
|
- 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) + "]+");
|
|
|
}
|
|
|
},
|
|
|
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));
|
|
|
- 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,
|
|
|
- c: chrs,
|
|
|
+ c: "-" === chrs ? opts.negationSymbol.front : "+",
|
|
|
remove: matchRslt.index,
|
|
|
caret: pos
|
|
|
- } : maskset.buffer[matchRslt.index] == ("-" === chrs ? "-" : "+") ? {
|
|
|
+ } : maskset.buffer[matchRslt.index] == ("-" === chrs ? opts.negationSymbol.front : "+") ? {
|
|
|
remove: matchRslt.index,
|
|
|
caret: pos - 1
|
|
|
} : {
|
|
|
pos: matchRslt.index,
|
|
|
- c: chrs,
|
|
|
+ c: "-" === chrs ? opts.negationSymbol.front : "+",
|
|
|
caret: pos + 1
|
|
|
};
|
|
|
}
|
|
|
@@ -1988,7 +1992,17 @@
|
|
|
"+": {
|
|
|
validator: function(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;
|
|
|
},
|
|
|
cardinality: 1,
|
|
|
@@ -2040,12 +2054,16 @@
|
|
|
canClearPosition: function(maskset, position, lvp, strict, opts) {
|
|
|
var positionInput = maskset.validPositions[position].input, canClear = positionInput != opts.radixPoint && isFinite(positionInput) || position == lvp || positionInput == opts.groupSeparator;
|
|
|
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 = [];
|
|
|
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"), ""));
|
|
|
-1 != radixPosition && 10 > intPart && "0" == opts.placeholder.charAt(0) && (maskset.validPositions[position].input = "0",
|
|
|
maskset.p = opts.prefix.length + 1, canClear = !1);
|