Browse Source

minor fix for numerics

Robin Herbots 11 years ago
parent
commit
d2834ae595

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
     "name": "jquery.inputmask",
-    "version": "3.0.34",
+    "version": "3.0.35",
     "main": "./dist/jquery.inputmask.bundle.js",
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "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.minor = 0
-build.revision = 34
+build.revision = 35
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.3.0.34.nupkg


BIN
dist/jQuery.InputMask.3.0.35.nupkg


+ 24 - 20
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.34
+* Version: 3.0.35
 */
 
 (function ($) {
@@ -586,14 +586,18 @@
                                     return false;//breakout if refreshFromBuffer && nothing to insert
                                 }
                                 validatedPos = rslt.pos != undefined ? rslt.pos : position;
-                                if (validatedPos != position)
-                                    tst = getTests(validatedPos)[0]; //possible mismatch TODO
+                                if (validatedPos != position) {
+                                    rslt = isValid(validatedPos, elem, true, true); //revalidate new position strict
+                                    return false;
+                                }
 
                             } else if (rslt !== true && rslt["pos"] != position) { //their is a position offset
                                 validatedPos = rslt["pos"];
                                 refreshFromBuffer(position, validatedPos);
-                                if (validatedPos != position)
-                                    tst = getTests(validatedPos)[0]; //possible mismatch TODO
+                                if (validatedPos != position) {
+                                    rslt = isValid(validatedPos, elem, true, true); //revalidate new position strict
+                                    return false;
+                                }
                             }
                             if (ndx > 0) {
                                 resetMaskSet(true);
@@ -1651,7 +1655,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.0.34
+* Version: 3.0.35
 */
 
 (function ($) {
@@ -2016,7 +2020,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.34
+Version: 3.0.35
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2137,7 +2141,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.34
+Version: 3.0.35
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2600,7 +2604,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.34
+Version: 3.0.35
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2728,18 +2732,18 @@ Optional extensions on the jquery.inputmask base
                     validator: function (chrs, buffer, pos, strict, opts) {
                         var isValid = opts.negationhandler(chrs, buffer, pos, strict, opts);
                         if (!isValid) {
-                            //handle 0 for integerpart
-                            //if (!strict && chrs === "0") {
-                            //    var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
-                            //    if (matchRslt && matchRslt[matchRslt.index].indexOf("0") == -1) {
-                            //        return false;
-                            //    }
-                            //}
-
                             isValid = strict ? new RegExp("[0-9" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
 
+                            //handle 0 for integerpart
+                            if (isValid != false) {
+                                var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
+                                if (matchRslt && matchRslt["0"][0] == 0 && pos > opts.prefix.length && ($.inArray(opts.radixPoint, buffer) == -1 || pos < $.inArray(opts.radixPoint, buffer))) {
+                                    buffer.splice(matchRslt.index, 1);
+                                    return { "pos": matchRslt.index, "c": chrs, "refreshFromBuffer": true, "caret": pos };
+                                }
+                            }
                             if (isValid != false && !strict && chrs != opts.radixPoint && opts.autoGroup === true) {
-                                return opts.postFormat(buffer, pos, (chrs == "-" || chrs == "+") ? true : false, opts);
+                                isValid = opts.postFormat(buffer, pos, (chrs == "-" || chrs == "+") ? true : false, opts);
                             }
                         }
                         return isValid;
@@ -2777,7 +2781,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.34
+Version: 3.0.35
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
@@ -2964,7 +2968,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 3.0.34
+Version: 3.0.35
 
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks

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


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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 8 - 4
js/jquery.inputmask.js

@@ -586,14 +586,18 @@
                                     return false;//breakout if refreshFromBuffer && nothing to insert
                                 }
                                 validatedPos = rslt.pos != undefined ? rslt.pos : position;
-                                if (validatedPos != position)
-                                    tst = getTests(validatedPos)[0]; //possible mismatch TODO
+                                if (validatedPos != position) {
+                                    rslt = isValid(validatedPos, elem, true, true); //revalidate new position strict
+                                    return false;
+                                }
 
                             } else if (rslt !== true && rslt["pos"] != position) { //their is a position offset
                                 validatedPos = rslt["pos"];
                                 refreshFromBuffer(position, validatedPos);
-                                if (validatedPos != position)
-                                    tst = getTests(validatedPos)[0]; //possible mismatch TODO
+                                if (validatedPos != position) {
+                                    rslt = isValid(validatedPos, elem, true, true); //revalidate new position strict
+                                    return false;
+                                }
                             }
                             if (ndx > 0) {
                                 resetMaskSet(true);

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

@@ -131,18 +131,18 @@ Optional extensions on the jquery.inputmask base
                     validator: function (chrs, buffer, pos, strict, opts) {
                         var isValid = opts.negationhandler(chrs, buffer, pos, strict, opts);
                         if (!isValid) {
-                            //handle 0 for integerpart
-                            //if (!strict && chrs === "0") {
-                            //    var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
-                            //    if (matchRslt && matchRslt[matchRslt.index].indexOf("0") == -1) {
-                            //        return false;
-                            //    }
-                            //}
-
                             isValid = strict ? new RegExp("[0-9" + $.inputmask.escapeRegex.call(this, opts.groupSeparator) + "]").test(chrs) : new RegExp("[0-9]").test(chrs);
 
+                            //handle 0 for integerpart
+                            if (isValid != false) {
+                                var matchRslt = buffer.join('').match(opts.regex.integerPart(opts));
+                                if (matchRslt && matchRslt["0"][0] == 0 && pos > opts.prefix.length && ($.inArray(opts.radixPoint, buffer) == -1 || pos < $.inArray(opts.radixPoint, buffer))) {
+                                    buffer.splice(matchRslt.index, 1);
+                                    return { "pos": matchRslt.index, "c": chrs, "refreshFromBuffer": true, "caret": pos };
+                                }
+                            }
                             if (isValid != false && !strict && chrs != opts.radixPoint && opts.autoGroup === true) {
-                                return opts.postFormat(buffer, pos, (chrs == "-" || chrs == "+") ? true : false, opts);
+                                isValid = opts.postFormat(buffer, pos, (chrs == "-" || chrs == "+") ? true : false, opts);
                             }
                         }
                         return isValid;