浏览代码

minor fix for numerics

Robin Herbots 11 年之前
父节点
当前提交
d2834ae595

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "3.0.34",
+    "version": "3.0.35",
     "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 = 34
+build.revision = 35
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

二进制
dist/jQuery.InputMask.3.0.34.nupkg


二进制
dist/jQuery.InputMask.3.0.35.nupkg


+ 24 - 20
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.34
+* Version: 3.0.35
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -586,14 +586,18 @@
                                     return false;//breakout if refreshFromBuffer && nothing to insert
                                     return false;//breakout if refreshFromBuffer && nothing to insert
                                 }
                                 }
                                 validatedPos = rslt.pos != undefined ? rslt.pos : position;
                                 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
                             } else if (rslt !== true && rslt["pos"] != position) { //their is a position offset
                                 validatedPos = rslt["pos"];
                                 validatedPos = rslt["pos"];
                                 refreshFromBuffer(position, validatedPos);
                                 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) {
                             if (ndx > 0) {
                                 resetMaskSet(true);
                                 resetMaskSet(true);
@@ -1651,7 +1655,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.34
+* Version: 3.0.35
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -2016,7 +2020,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.34
+Version: 3.0.35
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2137,7 +2141,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.34
+Version: 3.0.35
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2600,7 +2604,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.34
+Version: 3.0.35
 
 
 Optional extensions on the jquery.inputmask base
 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) {
                     validator: function (chrs, buffer, pos, strict, opts) {
                         var isValid = opts.negationhandler(chrs, buffer, pos, strict, opts);
                         var isValid = opts.negationhandler(chrs, buffer, pos, strict, opts);
                         if (!isValid) {
                         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);
                             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) {
                             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;
                         return isValid;
@@ -2777,7 +2781,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.34
+Version: 3.0.35
 
 
 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
@@ -2964,7 +2968,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.34
+Version: 3.0.35
 
 
 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

文件差异内容过多而无法显示
+ 89 - 89
dist/jquery.inputmask.bundle.min.js


文件差异内容过多而无法显示
+ 1 - 1
dist/min/jquery.inputmask-multi.js


文件差异内容过多而无法显示
+ 52 - 52
dist/min/jquery.inputmask.js


文件差异内容过多而无法显示
+ 6 - 6
dist/min/jquery.inputmask.numeric.extensions.js


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "3.0.34",
+    "version": "3.0.35",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "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
                                     return false;//breakout if refreshFromBuffer && nothing to insert
                                 }
                                 }
                                 validatedPos = rslt.pos != undefined ? rslt.pos : position;
                                 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
                             } else if (rslt !== true && rslt["pos"] != position) { //their is a position offset
                                 validatedPos = rslt["pos"];
                                 validatedPos = rslt["pos"];
                                 refreshFromBuffer(position, validatedPos);
                                 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) {
                             if (ndx > 0) {
                                 resetMaskSet(true);
                                 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) {
                     validator: function (chrs, buffer, pos, strict, opts) {
                         var isValid = opts.negationhandler(chrs, buffer, pos, strict, opts);
                         var isValid = opts.negationhandler(chrs, buffer, pos, strict, opts);
                         if (!isValid) {
                         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);
                             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) {
                             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;
                         return isValid;