Browse Source

numeric extensions tweaks

Robin Herbots 11 years ago
parent
commit
61dd19db0b

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "3.0.11",
+    "version": "3.0.12",
     "main": "./dist/jquery.inputmask.bundle.js",
     "main": "./dist/jquery.inputmask.bundle.js",
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 3
 build.major = 3
 build.minor = 0
 build.minor = 0
-build.revision = 11
+build.revision = 12
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.3.0.11.nupkg


BIN
dist/jQuery.InputMask.3.0.12.nupkg


+ 60 - 22
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.11
+* Version: 3.0.12
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -240,7 +240,7 @@
             //maskset helperfunctions
             //maskset helperfunctions
             function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
             function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
                 minimalPos = minimalPos || 0;
                 minimalPos = minimalPos || 0;
-                var maskTemplate = [], ndxIntlzr, pos = 0, test;
+                var maskTemplate = [], ndxIntlzr, pos = 0, test, testPos;
                 do {
                 do {
                     if (baseOnInput === true && getMaskSet()['validPositions'][pos]) {
                     if (baseOnInput === true && getMaskSet()['validPositions'][pos]) {
                         var validPos = getMaskSet()['validPositions'][pos];
                         var validPos = getMaskSet()['validPositions'][pos];
@@ -248,8 +248,12 @@
                         ndxIntlzr = validPos["locator"].slice();
                         ndxIntlzr = validPos["locator"].slice();
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                     } else {
                     } else {
-                        var testPos = getTests(pos, ndxIntlzr, pos - 1), firstMatch = testPos[0]["match"];
-                        testPos = testPos[(minimalPos > pos || (opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true))) ? 0 : (testPos.length - 1)];
+                        if (minimalPos > pos) {
+                            var testPositions = getTests(pos, ndxIntlzr, pos - 1);
+                            testPos = testPositions[0];
+                        } else {
+                            testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
+                        }
                         test = testPos["match"];
                         test = testPos["match"];
                         ndxIntlzr = testPos["locator"].slice();
                         ndxIntlzr = testPos["locator"].slice();
                         maskTemplate.push(test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length));
                         maskTemplate.push(test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length));
@@ -296,9 +300,10 @@
                     var valid = true;
                     var valid = true;
                     for (i = pos; i <= lvp ;) {
                     for (i = pos; i <= lvp ;) {
                         var j = seekNext(i);
                         var j = seekNext(i);
+                        if (i == j) valid = false;
                         var t = positionsClone[i];
                         var t = positionsClone[i];
                         if (t != undefined) {
                         if (t != undefined) {
-                            var nextTest = getTest(j, t["locator"].slice(), i);
+                            var nextTest = getTest(j);
                             if (nextTest.fn == null && nextTest.def == "")
                             if (nextTest.fn == null && nextTest.def == "")
                                 valid = false;
                                 valid = false;
                             else if (t["match"].fn == null || t["match"].def == nextTest.def) {
                             else if (t["match"].fn == null || t["match"].def == nextTest.def) {
@@ -344,12 +349,22 @@
                 resetMaskSet(true);
                 resetMaskSet(true);
             }
             }
 
 
-            function getTest(pos, ndxIntlzr, tstPs) {
+            function getTestTemplate(pos, ndxIntlzr, tstPs) {
+                var testPositions = getTests(pos, ndxIntlzr, tstPs), testPos;
+                for (var ndx in testPositions) {
+                    testPos = testPositions[ndx];
+                    if (opts.greedy || ((testPos["match"].optionality === false || testPos["match"].newBlockMarker === false) && testPos["match"].optionalQuantifier !== true)) {
+                        break;
+                    }
+                }
+
+                return testPos;
+            }
+            function getTest(pos) {
                 if (getMaskSet()['validPositions'][pos]) {
                 if (getMaskSet()['validPositions'][pos]) {
                     return getMaskSet()['validPositions'][pos]["match"];
                     return getMaskSet()['validPositions'][pos]["match"];
                 }
                 }
-                var testPos = getTests(pos, ndxIntlzr, tstPs);
-                return testPos[0]["match"];
+                return getTests(pos)[0]["match"];
             }
             }
 
 
             function getTests(pos, ndxIntlzr, tstPs) {
             function getTests(pos, ndxIntlzr, tstPs) {
@@ -584,9 +599,7 @@
                     var pos, lvp = getLastValidPosition(), testPos = getMaskSet()["validPositions"][lvp],
                     var pos, lvp = getLastValidPosition(), testPos = getMaskSet()["validPositions"][lvp],
                         ndxIntlzr = testPos != undefined ? testPos["locator"].slice() : undefined;
                         ndxIntlzr = testPos != undefined ? testPos["locator"].slice() : undefined;
                     for (pos = lvp + 1; testPos == undefined || (testPos["match"]["fn"] != null || (testPos["match"]["fn"] == null && testPos["match"]["def"] != "")) ; pos++) {
                     for (pos = lvp + 1; testPos == undefined || (testPos["match"]["fn"] != null || (testPos["match"]["fn"] == null && testPos["match"]["def"] != "")) ; pos++) {
-                        testPos = getTests(pos, ndxIntlzr, pos - 1);
-                        var firstMatch = testPos[0]["match"];
-                        testPos = testPos[(opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true)) ? 0 : (testPos.length - 1)];
+                        testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                         ndxIntlzr = testPos["locator"].slice();
                         ndxIntlzr = testPos["locator"].slice();
                     }
                     }
                     maskLength = pos;
                     maskLength = pos;
@@ -664,11 +677,9 @@
                     pos, lvp = getLastValidPosition(), positions = {},
                     pos, lvp = getLastValidPosition(), positions = {},
                     ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
                     ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
                 for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
                 for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
-                    testPos = getTests(pos, ndxIntlzr, pos - 1);
-                    var firstMatch = testPos[0]["match"];
-                    testPos = testPos[(opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true)) ? 0 : (testPos.length - 1)];
-                    positions[pos] = testPos;
+                    testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                     ndxIntlzr = testPos["locator"].slice();
                     ndxIntlzr = testPos["locator"].slice();
+                    positions[pos] = testPos;
                 }
                 }
 
 
                 for (pos = tmpBuffer.length - 1; pos > lvp; pos--) {
                 for (pos = tmpBuffer.length - 1; pos > lvp; pos--) {
@@ -1848,7 +1859,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.11
+Version: 3.0.12
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1958,7 +1969,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.11
+Version: 3.0.12
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2421,7 +2432,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.11
+Version: 3.0.12
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2430,11 +2441,15 @@ Optional extensions on the jquery.inputmask base
     $.extend($.inputmask.defaults.aliases, {
     $.extend($.inputmask.defaults.aliases, {
         'numeric': {
         'numeric': {
             mask: function (opts) {
             mask: function (opts) {
+                if (opts.repeat !== 0 && isNaN(opts.integerDigits)) {
+                    opts.integerDigits = opts.repeat;
+                }
+                opts.repeat = 0;
                 var mask = opts.prefix;
                 var mask = opts.prefix;
                 mask += "[+]";
                 mask += "[+]";
                 mask += "~{1," + opts.integerDigits + "}";
                 mask += "~{1," + opts.integerDigits + "}";
-                if (parseInt(opts.digits) > 0)
-                    mask += "[" + opts.radixPoint + "~{" + opts.digits + "}]";
+                if (opts.digits != undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))
+                    mask += "[" + opts.radixPoint + "={" + opts.digits + "}]";
                 mask += opts.suffix;
                 mask += opts.suffix;
                 return mask;
                 return mask;
             },
             },
@@ -2523,6 +2538,29 @@ Optional extensions on the jquery.inputmask base
                     cardinality: 1,
                     cardinality: 1,
                     prevalidator: null
                     prevalidator: null
                 },
                 },
+                '=': {
+                    validator: function (chrs, buffer, pos, strict, opts) {
+                        if (!strict && chrs === "-") {
+                            var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
+
+                            if (matchRslt.length > 0) {
+                                if (buffer[matchRslt.index] == "+") {
+                                    buffer.splice(matchRslt.index, 1);
+                                    return { "pos": matchRslt.index, "c": "-", "refreshFromBuffer": true, "caret": pos };
+                                } else if (buffer[matchRslt.index] == "-") {
+                                    buffer.splice(matchRslt.index, 1);
+                                    return { "refreshFromBuffer": true, "caret": pos - 1 };
+                                } else {
+                                    return { "pos": matchRslt.index, "c": "-", "caret": pos + 1 };
+                                }
+                            }
+                        }
+                        var isValid = new RegExp("[0-9]").test(chrs);
+                        return isValid;
+                    },
+                    cardinality: 1,
+                    prevalidator: null
+                },
                 '+': {
                 '+': {
                     validator: function (chrs, buffer, pos, strict, opts) {
                     validator: function (chrs, buffer, pos, strict, opts) {
                         var signed = "[";
                         var signed = "[";
@@ -2553,7 +2591,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.11
+Version: 3.0.12
 
 
 Regex extensions on the jquery.inputmask base
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask
@@ -2740,7 +2778,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.11
+Version: 3.0.12
 
 
 Phone extension.
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks
 When using this extension make sure you specify the correct url to get the masks

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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "3.0.11",
+    "version": "3.0.12",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 25 - 14
js/jquery.inputmask.js

@@ -240,7 +240,7 @@
             //maskset helperfunctions
             //maskset helperfunctions
             function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
             function getMaskTemplate(baseOnInput, minimalPos, includeInput) {
                 minimalPos = minimalPos || 0;
                 minimalPos = minimalPos || 0;
-                var maskTemplate = [], ndxIntlzr, pos = 0, test;
+                var maskTemplate = [], ndxIntlzr, pos = 0, test, testPos;
                 do {
                 do {
                     if (baseOnInput === true && getMaskSet()['validPositions'][pos]) {
                     if (baseOnInput === true && getMaskSet()['validPositions'][pos]) {
                         var validPos = getMaskSet()['validPositions'][pos];
                         var validPos = getMaskSet()['validPositions'][pos];
@@ -248,8 +248,12 @@
                         ndxIntlzr = validPos["locator"].slice();
                         ndxIntlzr = validPos["locator"].slice();
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                         maskTemplate.push(test["fn"] == null ? test["def"] : (includeInput === true ? validPos["input"] : opts.placeholder.charAt(pos % opts.placeholder.length)));
                     } else {
                     } else {
-                        var testPos = getTests(pos, ndxIntlzr, pos - 1), firstMatch = testPos[0]["match"];
-                        testPos = testPos[(minimalPos > pos || (opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true))) ? 0 : (testPos.length - 1)];
+                        if (minimalPos > pos) {
+                            var testPositions = getTests(pos, ndxIntlzr, pos - 1);
+                            testPos = testPositions[0];
+                        } else {
+                            testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
+                        }
                         test = testPos["match"];
                         test = testPos["match"];
                         ndxIntlzr = testPos["locator"].slice();
                         ndxIntlzr = testPos["locator"].slice();
                         maskTemplate.push(test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length));
                         maskTemplate.push(test["fn"] == null ? test["def"] : opts.placeholder.charAt(pos % opts.placeholder.length));
@@ -296,9 +300,10 @@
                     var valid = true;
                     var valid = true;
                     for (i = pos; i <= lvp ;) {
                     for (i = pos; i <= lvp ;) {
                         var j = seekNext(i);
                         var j = seekNext(i);
+                        if (i == j) valid = false;
                         var t = positionsClone[i];
                         var t = positionsClone[i];
                         if (t != undefined) {
                         if (t != undefined) {
-                            var nextTest = getTest(j, t["locator"].slice(), i);
+                            var nextTest = getTest(j);
                             if (nextTest.fn == null && nextTest.def == "")
                             if (nextTest.fn == null && nextTest.def == "")
                                 valid = false;
                                 valid = false;
                             else if (t["match"].fn == null || t["match"].def == nextTest.def) {
                             else if (t["match"].fn == null || t["match"].def == nextTest.def) {
@@ -344,12 +349,22 @@
                 resetMaskSet(true);
                 resetMaskSet(true);
             }
             }
 
 
-            function getTest(pos, ndxIntlzr, tstPs) {
+            function getTestTemplate(pos, ndxIntlzr, tstPs) {
+                var testPositions = getTests(pos, ndxIntlzr, tstPs), testPos;
+                for (var ndx in testPositions) {
+                    testPos = testPositions[ndx];
+                    if (opts.greedy || ((testPos["match"].optionality === false || testPos["match"].newBlockMarker === false) && testPos["match"].optionalQuantifier !== true)) {
+                        break;
+                    }
+                }
+
+                return testPos;
+            }
+            function getTest(pos) {
                 if (getMaskSet()['validPositions'][pos]) {
                 if (getMaskSet()['validPositions'][pos]) {
                     return getMaskSet()['validPositions'][pos]["match"];
                     return getMaskSet()['validPositions'][pos]["match"];
                 }
                 }
-                var testPos = getTests(pos, ndxIntlzr, tstPs);
-                return testPos[0]["match"];
+                return getTests(pos)[0]["match"];
             }
             }
 
 
             function getTests(pos, ndxIntlzr, tstPs) {
             function getTests(pos, ndxIntlzr, tstPs) {
@@ -584,9 +599,7 @@
                     var pos, lvp = getLastValidPosition(), testPos = getMaskSet()["validPositions"][lvp],
                     var pos, lvp = getLastValidPosition(), testPos = getMaskSet()["validPositions"][lvp],
                         ndxIntlzr = testPos != undefined ? testPos["locator"].slice() : undefined;
                         ndxIntlzr = testPos != undefined ? testPos["locator"].slice() : undefined;
                     for (pos = lvp + 1; testPos == undefined || (testPos["match"]["fn"] != null || (testPos["match"]["fn"] == null && testPos["match"]["def"] != "")) ; pos++) {
                     for (pos = lvp + 1; testPos == undefined || (testPos["match"]["fn"] != null || (testPos["match"]["fn"] == null && testPos["match"]["def"] != "")) ; pos++) {
-                        testPos = getTests(pos, ndxIntlzr, pos - 1);
-                        var firstMatch = testPos[0]["match"];
-                        testPos = testPos[(opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true)) ? 0 : (testPos.length - 1)];
+                        testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                         ndxIntlzr = testPos["locator"].slice();
                         ndxIntlzr = testPos["locator"].slice();
                     }
                     }
                     maskLength = pos;
                     maskLength = pos;
@@ -664,11 +677,9 @@
                     pos, lvp = getLastValidPosition(), positions = {},
                     pos, lvp = getLastValidPosition(), positions = {},
                     ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
                     ndxIntlzr = getMaskSet()["validPositions"][lvp]["locator"].slice(), testPos;
                 for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
                 for (pos = lvp + 1; pos < tmpBuffer.length; pos++) {
-                    testPos = getTests(pos, ndxIntlzr, pos - 1);
-                    var firstMatch = testPos[0]["match"];
-                    testPos = testPos[(opts.greedy || (firstMatch.optionality === true && firstMatch.newBlockMarker === false && firstMatch.optionalQuantifier !== true)) ? 0 : (testPos.length - 1)];
-                    positions[pos] = testPos;
+                    testPos = getTestTemplate(pos, ndxIntlzr, pos - 1);
                     ndxIntlzr = testPos["locator"].slice();
                     ndxIntlzr = testPos["locator"].slice();
+                    positions[pos] = testPos;
                 }
                 }
 
 
                 for (pos = tmpBuffer.length - 1; pos > lvp; pos--) {
                 for (pos = tmpBuffer.length - 1; pos > lvp; pos--) {

+ 29 - 2
js/jquery.inputmask.numeric.extensions.js

@@ -12,11 +12,15 @@ Optional extensions on the jquery.inputmask base
     $.extend($.inputmask.defaults.aliases, {
     $.extend($.inputmask.defaults.aliases, {
         'numeric': {
         'numeric': {
             mask: function (opts) {
             mask: function (opts) {
+                if (opts.repeat !== 0 && isNaN(opts.integerDigits)) {
+                    opts.integerDigits = opts.repeat;
+                }
+                opts.repeat = 0;
                 var mask = opts.prefix;
                 var mask = opts.prefix;
                 mask += "[+]";
                 mask += "[+]";
                 mask += "~{1," + opts.integerDigits + "}";
                 mask += "~{1," + opts.integerDigits + "}";
-                if (parseInt(opts.digits) > 0)
-                    mask += "[" + opts.radixPoint + "~{" + opts.digits + "}]";
+                if (opts.digits != undefined && (isNaN(opts.digits) || parseInt(opts.digits) > 0))
+                    mask += "[" + opts.radixPoint + "={" + opts.digits + "}]";
                 mask += opts.suffix;
                 mask += opts.suffix;
                 return mask;
                 return mask;
             },
             },
@@ -105,6 +109,29 @@ Optional extensions on the jquery.inputmask base
                     cardinality: 1,
                     cardinality: 1,
                     prevalidator: null
                     prevalidator: null
                 },
                 },
+                '=': {
+                    validator: function (chrs, buffer, pos, strict, opts) {
+                        if (!strict && chrs === "-") {
+                            var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
+
+                            if (matchRslt.length > 0) {
+                                if (buffer[matchRslt.index] == "+") {
+                                    buffer.splice(matchRslt.index, 1);
+                                    return { "pos": matchRslt.index, "c": "-", "refreshFromBuffer": true, "caret": pos };
+                                } else if (buffer[matchRslt.index] == "-") {
+                                    buffer.splice(matchRslt.index, 1);
+                                    return { "refreshFromBuffer": true, "caret": pos - 1 };
+                                } else {
+                                    return { "pos": matchRslt.index, "c": "-", "caret": pos + 1 };
+                                }
+                            }
+                        }
+                        var isValid = new RegExp("[0-9]").test(chrs);
+                        return isValid;
+                    },
+                    cardinality: 1,
+                    prevalidator: null
+                },
                 '+': {
                 '+': {
                     validator: function (chrs, buffer, pos, strict, opts) {
                     validator: function (chrs, buffer, pos, strict, opts) {
                         var signed = "[";
                         var signed = "[";

+ 3 - 26
qunit/tests.js

@@ -1221,15 +1221,12 @@ test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - inp
     $("#testmask")[0].focus();
     $("#testmask")[0].focus();
 
 
     $("#testmask").Type("12345.123");
     $("#testmask").Type("12345.123");
-    $("#testmask")[0].focus();
-    //$("#testmask").click();
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
-    $("#testmask").SendKey(keyCodes.BACKSPACE);
 
 
     equal($("#testmask").val(), "12,345", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "12,345", "Result " + $("#testmask").val());
     $("#testmask").remove();
     $("#testmask").remove();
@@ -1242,16 +1239,13 @@ test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - inp
     $("#testmask")[0].focus();
     $("#testmask")[0].focus();
 
 
     $("#testmask").Type("12345.123");
     $("#testmask").Type("12345.123");
-    //$("#testmask").click();
-    $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
-    $("#testmask").SendKey(keyCodes.DELETE);
-    $("#testmask").Type("789");
+    $("#testmask").Type(".789");
 
 
     equal($("#testmask").val(), "12,345.789", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "12,345.789", "Result " + $("#testmask").val());
     $("#testmask").remove();
     $("#testmask").remove();
@@ -1283,12 +1277,9 @@ test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\" }\") - in
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
-    $("#testmask").SendKey(keyCodes.LEFT);
-    $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
-    $("#testmask").SendKey(keyCodes.BACKSPACE);
 
 
     equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
     $("#testmask").remove();
     $("#testmask").remove();
@@ -1301,7 +1292,6 @@ test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\" }\") - in
     $("#testmask")[0].focus();
     $("#testmask")[0].focus();
 
 
     $("#testmask").Type("12345.123");
     $("#testmask").Type("12345.123");
-    //$("#testmask").click();
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
     $("#testmask").SendKey(keyCodes.LEFT);
@@ -1309,7 +1299,7 @@ test("inputmask(\"decimal\", { autoGroup: false, groupSeparator: \",\" }\") - in
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
     $("#testmask").SendKey(keyCodes.DELETE);
-    $("#testmask").Type("789");
+    $("#testmask").Type(".789");
 
 
     equal($("#testmask").val(), "12345.789", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "12345.789", "Result " + $("#testmask").val());
     $("#testmask").remove();
     $("#testmask").remove();
@@ -1350,7 +1340,7 @@ test("inputmask(\"decimal, { repeat: 5 }\") - maxlength 10", function () {
 
 
     $("#testmask").Type("123456789012345");
     $("#testmask").Type("123456789012345");
 
 
-    equal($("#testmask").val(), "12345", "Result " + $("#testmask").val());
+    equal($("#testmask").val(), "12345.6789", "Result " + $("#testmask").val());
     $("#testmask").remove();
     $("#testmask").remove();
 });
 });
 
 
@@ -1412,19 +1402,6 @@ test("inputmask(\"decimal\") - value=\"1234567890\"", function () {
     $("#testmask").remove();
     $("#testmask").remove();
 });
 });
 
 
-test("inputmask(\"decimal\") - value=\"123.1\" tab out", function () {
-    var $fixture = $("#qunit-fixture");
-    $fixture.append('<input type="text" id="testmask" />');
-    $("#testmask").inputmask("decimal", { digits: 3 });
-
-    $("#testmask")[0].focus();
-    $("#testmask").Type("123.1");
-    $("#testmask").SendKey(keyCodes.TAB);
-
-    equal($("#testmask").val(), "123.100", "Result " + $("#testmask").val());
-    $("#testmask").remove();
-});
-
 test("inputmask(\"decimal\") - value=\"123.45\" Replace last integer", function () {
 test("inputmask(\"decimal\") - value=\"123.45\" Replace last integer", function () {
     var $fixture = $("#qunit-fixture");
     var $fixture = $("#qunit-fixture");
     $fixture.append('<input type="text" id="testmask" />');
     $fixture.append('<input type="text" id="testmask" />');