Robin Herbots 12 年 前
コミット
d91f958b08
1 ファイル変更11 行追加8 行削除
  1. 11 8
      js/jquery.inputmask.js

+ 11 - 8
js/jquery.inputmask.js

@@ -375,9 +375,12 @@
                             } else if (match.isQuantifier && quantifierRecurse !== true) {
                             } else if (match.isQuantifier && quantifierRecurse !== true) {
                                 var qt = match;
                                 var qt = match;
                                 for (var qndx = (ndxInitializer.length > 0 && quantifierRecurse !== true) ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) ; qndx++) {
                                 for (var qndx = (ndxInitializer.length > 0 && quantifierRecurse !== true) ? ndxInitializer.shift() : 0; qndx < (isNaN(qt.quantifier.max) ? qndx + 1 : qt.quantifier.max) ; qndx++) {
-                                    match = handleMatch(maskToken.matches[maskToken.matches.indexOf(qt) - 1], [qndx].concat(loopNdx), true);
+                                    var tokenGroup = maskToken.matches[maskToken.matches.indexOf(qt) - 1];
+                                    match = handleMatch(tokenGroup, [qndx].concat(loopNdx), true);
                                     if (match) {
                                     if (match) {
-                                        if (qndx >= qt.quantifier.min) { //search for next possible match
+                                        //get latest match
+                                        var latestMatch = matches[matches.length - 1]["match"];
+                                        if (qndx >= qt.quantifier.min && (tokenGroup.matches.indexOf(latestMatch) == (tokenGroup.matches.length -1))) { //search for next possible match
                                             if (isNaN(qt.quantifier.max) && qndx > qt.quantifier.min) {
                                             if (isNaN(qt.quantifier.max) && qndx > qt.quantifier.min) {
                                                 matches.push({ "match": { fn: null, cardinality: 0, optionality: true, casing: null, def: "" }, "locator": [] });
                                                 matches.push({ "match": { fn: null, cardinality: 0, optionality: true, casing: null, def: "" }, "locator": [] });
                                                 return true;
                                                 return true;
@@ -1384,11 +1387,11 @@
                 //backspace in chrome32 only fires input event - detect & treat
                 //backspace in chrome32 only fires input event - detect & treat
                 var caretPos = caret(input),
                 var caretPos = caret(input),
                     currentValue = input._valueGet();
                     currentValue = input._valueGet();
-                if (currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin] 
-              	  	&& currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin] 
+                if (currentValue.charAt(caretPos.begin) != getActiveBuffer()[caretPos.begin]
+              	  	&& currentValue.charAt(caretPos.begin + 1) != getActiveBuffer()[caretPos.begin]
                 	&& !isMask(caretPos.begin)) {
                 	&& !isMask(caretPos.begin)) {
-                    	e.keyCode = opts.keyCode.BACKSPACE;
-                    	keydownEvent.call(input, e);
+                    e.keyCode = opts.keyCode.BACKSPACE;
+                    keydownEvent.call(input, e);
                 } else { //nonnumerics don't fire keypress 
                 } else { //nonnumerics don't fire keypress 
                     checkVal(input, false, false);
                     checkVal(input, false, false);
                     writeBuffer(input, getActiveBuffer());
                     writeBuffer(input, getActiveBuffer());
@@ -1396,7 +1399,7 @@
                         $input.trigger("complete");
                         $input.trigger("complete");
                     $input.click();
                     $input.click();
                 }
                 }
-                e.preventDefault()
+                e.preventDefault();
             }
             }
 
 
             function mask(el) {
             function mask(el) {
@@ -1589,7 +1592,7 @@
 
 
                     if (androidchrome32 || androidchrome18 || androidchrome29) {
                     if (androidchrome32 || androidchrome18 || androidchrome29) {
                         $el.bind("input.inputmask", chrome32InputEvent);
                         $el.bind("input.inputmask", chrome32InputEvent);
-                    }    
+                    }
                     if (msie1x)
                     if (msie1x)
                         $el.bind("input.inputmask", inputEvent);
                         $el.bind("input.inputmask", inputEvent);