浏览代码

small fix in isvalid

Robin Herbots 9 年之前
父节点
当前提交
93bf10f058
共有 4 个文件被更改,包括 36 次插入2 次删除
  1. 1 0
      CHANGELOG.md
  2. 2 2
      js/inputmask.js
  3. 1 0
      qunit/main.js
  4. 32 0
      qunit/tests_alternations.js

+ 1 - 0
CHANGELOG.md

@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
 - patchValueProperty - enable native value property patch on IE10/IE11
 - patchValueProperty - enable native value property patch on IE10/IE11
 
 
 ### Fixed
 ### Fixed
+- validate regular expression for indian vehicle registration number #1223
 - Distinguish empty value and '$ 0.00' value for currency alias #1053
 - Distinguish empty value and '$ 0.00' value for currency alias #1053
 - 'alias': 'numeric', zero value #1221
 - 'alias': 'numeric', zero value #1221
 - Clicking on a highlighted masked field does not set the caret to the first valid position (Chrome) #1218
 - Clicking on a highlighted masked field does not set the caret to the first valid position (Chrome) #1218

+ 2 - 2
js/inputmask.js

@@ -1196,7 +1196,7 @@
 				});
 				});
 			}
 			}
 			getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
 			getMaskSet().tests[pos] = $.extend(true, [], matches); //set a clone to prevent overwriting some props
-			// console.log(pos + " - " + JSON.stringify(matches));
+			//console.log(pos + " - " + JSON.stringify(matches));
 			return getMaskSet().tests[pos];
 			return getMaskSet().tests[pos];
 		}
 		}
 
 
@@ -1529,7 +1529,7 @@
 				if (getMaskSet().validPositions[pndx] === undefined &&
 				if (getMaskSet().validPositions[pndx] === undefined &&
 					((testTemplate = getTestTemplate(pndx)).match.def === opts.radixPointDefinitionSymbol || !isMask(pndx, true) ||
 					((testTemplate = getTestTemplate(pndx)).match.def === opts.radixPointDefinitionSymbol || !isMask(pndx, true) ||
 					($.inArray(opts.radixPoint, getBuffer()) < pndx && testTemplate.match.fn && testTemplate.match.fn.test(getPlaceholder(pndx), getMaskSet(), pndx, false, opts)))) {
 					($.inArray(opts.radixPoint, getBuffer()) < pndx && testTemplate.match.fn && testTemplate.match.fn.test(getPlaceholder(pndx), getMaskSet(), pndx, false, opts)))) {
-					_isValid(getLastValidPosition() + 1, testTemplate.match.placeholder || (testTemplate.match.fn == null ? testTemplate.match.def : (getPlaceholder(pndx) !== "" ? getPlaceholder(pndx) : getBuffer()[pndx])), true, fromSetValid);
+					_isValid(getLastValidPosition(pndx, true) + 1, testTemplate.match.placeholder || (testTemplate.match.fn == null ? testTemplate.match.def : (getPlaceholder(pndx) !== "" ? getPlaceholder(pndx) : getBuffer()[pndx])), true, fromSetValid);
 				}
 				}
 			}
 			}
 
 

+ 1 - 0
qunit/main.js

@@ -17,6 +17,7 @@ define([
 	"tests_regex",
 	"tests_regex",
 	"tests_escape",
 	"tests_escape",
 	"tests_attributes",
 	"tests_attributes",
+	"tests_alternations",
 	"tests_jquery_inputmask"
 	"tests_jquery_inputmask"
 ], function(qunit) {
 ], function(qunit) {
 	qunit.load();
 	qunit.load();

+ 32 - 0
qunit/tests_alternations.js

@@ -0,0 +1,32 @@
+define([
+	"qunit",
+	"inputmask.dependencyLib",
+	"inputmask",
+	"../dist/inputmask/inputmask.extensions",
+	"prototypeExtensions",
+	"simulator"
+], function (qunit, $, Inputmask) {
+	qunit.module("Alternations");
+
+	qunit.test("\"9{1,2}C|S A{1,3} 9{4}\" - ankitajain32", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("9{1,2}C|S A{1,3} 9{4}").mask(testmask);
+		$("#testmask").Type("12Cabc1234");
+		assert.equal(testmask.inputmask._valueGet(), "12C ABC 1234", "Result " + testmask.inputmask._valueGet());
+	});
+
+	qunit.test("\"9{1,2}C|S A{1,3} 9{4}\" replace C with S - ankitajain32", function (assert) {
+		var $fixture = $("#qunit-fixture");
+		$fixture.append('<input type="text" id="testmask" />');
+		var testmask = document.getElementById("testmask");
+
+		Inputmask("9{1,2}C|S A{1,3} 9{4}").mask(testmask);
+		$("#testmask").Type("12Cabc1234");
+		$.caret(testmask, 2, 3);
+		$("#testmask").Type("S");
+		assert.equal(testmask.inputmask._valueGet(), "12S ABC 1234", "Result " + testmask.inputmask._valueGet());
+	});
+});