Browse Source

fix lastvalidposition handling in isvalid fn

Robin Herbots 12 years ago
parent
commit
1f25f17916

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 build.major = 2
 build.minor = 2
-build.revision = 9
+build.revision = 10
 
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.2.2.10.nupkg


BIN
dist/jQuery.InputMask.2.2.9.nupkg


+ 21 - 6
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.2.9
+* Version: 2.2.10
 */
 
 (function ($) {
@@ -428,7 +428,20 @@
                     return activeMaskset['tests'][testPos].fn != null ? activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts) : false;
                 }
 
-                if (strict) return _isValid(pos, getActiveMaskSet()); //only check validity in current mask when validating strict
+                if (strict) {
+                    var rslt = _isValid(pos, getActiveMaskSet()); //only check validity in current mask when validating strict
+
+                    if (rslt !== false) {
+                        if (rslt === true) {
+                            rslt = { "pos": pos }; //always take a possible corrected maskposition into account
+                        }
+                        var activeMaskset = getActiveMaskSet();
+                        var newValidPosition = rslt.pos || pos;
+                        if (activeMaskset['lastValidPosition'] == undefined || activeMaskset['lastValidPosition'] < newValidPosition)
+                            activeMaskset['lastValidPosition'] = newValidPosition; //set new position from isValid
+                    }
+                    return rslt;
+                }
 
                 var results = [], result = false, currentActiveMasksetIndex = activeMasksetIndex;
                 $.each(masksets, function (index, value) {
@@ -458,7 +471,9 @@
                                 if (results[index] === true) {
                                     results[index] = { "pos": maskPos }; //always take a possible corrected maskposition into account
                                 }
-                                activeMaskset['lastValidPosition'] = results[index].pos || maskPos; //set new position from isValid
+                                var newValidPosition = results[index].pos || maskPos;
+                                if (activeMaskset['lastValidPosition'] == undefined || activeMaskset['lastValidPosition'] < newValidPosition)
+                                    activeMaskset['lastValidPosition'] = newValidPosition; //set new position from isValid
                             } else activeMaskset['lastValidPosition'] = isRTL ? pos == getMaskLength(buffer) ? undefined : seekNext(buffer, pos) : pos == 0 ? undefined : seekPrevious(buffer, pos); //autocorrect validposition from backspace etc  	
                         }
                     }
@@ -1329,7 +1344,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.9
+Version: 2.2.10
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1426,7 +1441,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.9
+Version: 2.2.10
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1919,7 +1934,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.9
+Version: 2.2.10
 
 Optional extensions on the jquery.inputmask base
 */

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


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


+ 1 - 0
dist/min/jquery.inputmask.regex.extensions.js

@@ -0,0 +1 @@
+(function(){})(jQuery);

+ 1 - 1
jquery.inputmask.jquery.json

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

+ 17 - 2
js/jquery.inputmask.js

@@ -428,7 +428,20 @@
                     return activeMaskset['tests'][testPos].fn != null ? activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts) : false;
                 }
 
-                if (strict) return _isValid(pos, getActiveMaskSet()); //only check validity in current mask when validating strict
+                if (strict) {
+                    var rslt = _isValid(pos, getActiveMaskSet()); //only check validity in current mask when validating strict
+
+                    if (rslt !== false) {
+                        if (rslt === true) {
+                            rslt = { "pos": pos }; //always take a possible corrected maskposition into account
+                        }
+                        var activeMaskset = getActiveMaskSet();
+                        var newValidPosition = rslt.pos || pos;
+                        if (activeMaskset['lastValidPosition'] == undefined || activeMaskset['lastValidPosition'] < newValidPosition)
+                            activeMaskset['lastValidPosition'] = newValidPosition; //set new position from isValid
+                    }
+                    return rslt;
+                }
 
                 var results = [], result = false, currentActiveMasksetIndex = activeMasksetIndex;
                 $.each(masksets, function (index, value) {
@@ -458,7 +471,9 @@
                                 if (results[index] === true) {
                                     results[index] = { "pos": maskPos }; //always take a possible corrected maskposition into account
                                 }
-                                activeMaskset['lastValidPosition'] = results[index].pos || maskPos; //set new position from isValid
+                                var newValidPosition = results[index].pos || maskPos;
+                                if (activeMaskset['lastValidPosition'] == undefined || activeMaskset['lastValidPosition'] < newValidPosition)
+                                    activeMaskset['lastValidPosition'] = newValidPosition; //set new position from isValid
                             } else activeMaskset['lastValidPosition'] = isRTL ? pos == getMaskLength(buffer) ? undefined : seekNext(buffer, pos) : pos == 0 ? undefined : seekPrevious(buffer, pos); //autocorrect validposition from backspace etc  	
                         }
                     }