|
|
@@ -129,17 +129,23 @@ Optional extensions on the jquery.inputmask base
|
|
|
integerPart: function (opts) { return new RegExp('[-\+]?\\d+'); },
|
|
|
integerNPart: function (opts) { return new RegExp('\\d+'); }
|
|
|
},
|
|
|
- signHandler: function (chrs, buffer, pos, strict, opts) {
|
|
|
- if (!strict && (opts.allowMinus && chrs === "-" || opts.allowPlus && chrs === "+")) {
|
|
|
- var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
|
|
|
+ signHandler: function (chrs, maskset, pos, strict, opts) {
|
|
|
+ if (!strict && (opts.allowMinus && chrs === "-" || opts.allowPlus && chrs === "+" || chrs === "0")) {
|
|
|
+ var matchRslt = maskset.buffer.join('').match(opts.regex.integerPart(opts));
|
|
|
|
|
|
- if (matchRslt && matchRslt.length > 0 && matchRslt[matchRslt.index] !== "0") {
|
|
|
- if (buffer[matchRslt.index] == (chrs === "-" ? "+" : "-")) {
|
|
|
- return { "pos": matchRslt.index, "c": chrs, "remove": matchRslt.index, "caret": pos };
|
|
|
- } else if (buffer[matchRslt.index] == (chrs === "-" ? "-" : "+")) {
|
|
|
- return { "remove": matchRslt.index, "caret": pos - 1 };
|
|
|
+ if (matchRslt && matchRslt.length > 0 && (matchRslt[matchRslt.index] !== "0" || (maskset.buffer && maskset._buffer && maskset.buffer.join('') != maskset._buffer.join('')))) {
|
|
|
+ if (chrs === "0") {
|
|
|
+ if (maskset.buffer[matchRslt.index] == "-" || maskset.buffer[matchRslt.index] == "+") {
|
|
|
+ return { "remove": matchRslt.index, "caret": pos - 1 };
|
|
|
+ }
|
|
|
} else {
|
|
|
- return { "pos": matchRslt.index, "c": chrs, "caret": pos + 1 };
|
|
|
+ if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "+" : "-")) {
|
|
|
+ return { "pos": matchRslt.index, "c": chrs, "remove": matchRslt.index, "caret": pos };
|
|
|
+ } else if (maskset.buffer[matchRslt.index] == (chrs === "-" ? "-" : "+")) {
|
|
|
+ return { "remove": matchRslt.index, "caret": pos - 1 };
|
|
|
+ } else {
|
|
|
+ return { "pos": matchRslt.index, "c": chrs, "caret": pos + 1 };
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -182,7 +188,7 @@ Optional extensions on the jquery.inputmask base
|
|
|
definitions: {
|
|
|
'~': {
|
|
|
validator: function (chrs, maskset, pos, strict, opts) {
|
|
|
- var isValid = opts.signHandler(chrs, maskset.buffer, pos, strict, opts);
|
|
|
+ var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
|
|
|
if (!isValid) {
|
|
|
isValid = opts.radixHandler(chrs, maskset, pos, strict, opts);
|
|
|
if (!isValid) {
|
|
|
@@ -207,7 +213,7 @@ Optional extensions on the jquery.inputmask base
|
|
|
},
|
|
|
'+': {
|
|
|
validator: function (chrs, maskset, pos, strict, opts) {
|
|
|
- var isValid = opts.signHandler(chrs, maskset.buffer, pos, strict, opts);
|
|
|
+ var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
|
|
|
if (!isValid) {
|
|
|
isValid = (opts.allowMinus && chrs == "-") || (opts.allowPlus && chrs == "+");
|
|
|
}
|
|
|
@@ -219,7 +225,7 @@ Optional extensions on the jquery.inputmask base
|
|
|
},
|
|
|
':': {
|
|
|
validator: function (chrs, maskset, pos, strict, opts) {
|
|
|
- var isValid = opts.signHandler(chrs, maskset.buffer, pos, strict, opts);
|
|
|
+ var isValid = opts.signHandler(chrs, maskset, pos, strict, opts);
|
|
|
if (!isValid) {
|
|
|
var radix = "[" + $.inputmask.escapeRegex.call(this, opts.radixPoint) + "]";
|
|
|
isValid = new RegExp(radix).test(chrs);
|