Browse Source

enhance checkval

Robin Herbots 11 years ago
parent
commit
60be89d8c6

+ 3 - 1
dist/inputmask/jquery.inputmask.js

@@ -526,7 +526,9 @@
         }
         }
         function checkVal(input, writeOut, strict, nptvl) {
         function checkVal(input, writeOut, strict, nptvl) {
             var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
             var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
-            if (resetMaskSet(), writeOut && input._valueSet(""), $.each(inputValue, function(ndx, charCode) {
+            resetMaskSet(), writeOut && input._valueSet("");
+            var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp(escapeRegex(staticInput), "g"));
+            if (matches && matches.length > 0 && inputValue.splice(0, staticInput.length), $.each(inputValue, function(ndx, charCode) {
                 var lvp = getLastValidPosition();
                 var lvp = getLastValidPosition();
                 -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
                 -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
                 strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);
                 strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);

+ 3 - 1
dist/jquery.inputmask.bundle.js

@@ -524,7 +524,9 @@
         }
         }
         function checkVal(input, writeOut, strict, nptvl) {
         function checkVal(input, writeOut, strict, nptvl) {
             var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
             var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
-            if (resetMaskSet(), writeOut && input._valueSet(""), $.each(inputValue, function(ndx, charCode) {
+            resetMaskSet(), writeOut && input._valueSet("");
+            var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(""), matches = inputValue.join("").match(new RegExp(escapeRegex(staticInput), "g"));
+            if (matches && matches.length > 0 && inputValue.splice(0, staticInput.length), $.each(inputValue, function(ndx, charCode) {
                 var lvp = getLastValidPosition();
                 var lvp = getLastValidPosition();
                 -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
                 -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
                 strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);
                 strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);

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


+ 6 - 0
js/jquery.inputmask.js

@@ -935,6 +935,12 @@
                 var inputValue = nptvl != undefined ? nptvl.slice() : input._valueGet().split('');
                 var inputValue = nptvl != undefined ? nptvl.slice() : input._valueGet().split('');
                 resetMaskSet();
                 resetMaskSet();
                 if (writeOut) input._valueSet(""); //initial clear
                 if (writeOut) input._valueSet(""); //initial clear
+
+                var staticInput = getBufferTemplate().slice(0, seekNext(-1)).join(''), matches = inputValue.join('').match(new RegExp(escapeRegex(staticInput), "g"));
+                if (matches && matches.length > 0) {
+                    inputValue.splice(0, staticInput.length);
+                }
+
                 $.each(inputValue, function (ndx, charCode) {
                 $.each(inputValue, function (ndx, charCode) {
                     var lvp = getLastValidPosition();
                     var lvp = getLastValidPosition();
                     if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet()["p"])) == -1 || strict) {
                     if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet()["p"])) == -1 || strict) {