Browse Source

fixed the issue #1410

Denis Velikanov 8 years ago
parent
commit
e8a31b4b09
1 changed files with 20 additions and 0 deletions
  1. 20 0
      js/inputmask.date.extensions.js

+ 20 - 0
js/inputmask.date.extensions.js

@@ -108,6 +108,16 @@
 			definitions: {
 				"1": { //val1 ~ day or month
 					validator: function (chrs, maskset, pos, strict, opts) {
+						if(chrs.charAt(0) == '3'){
+							var secondCharRgxp = new RegExp("[2-9]");
+							if(secondCharRgxp.test(chrs.charAt(1))){
+								chrs = '30';
+								return maskset.buffer[pos] = "0",
+								pos++, {
+									pos: pos
+								};
+							}
+						}
 						var isValid = opts.regex.val1.test(chrs);
 						if (!strict && !isValid) {
 							if (chrs.charAt(1) === opts.separator || "-./".indexOf(chrs.charAt(1)) !== -1) {
@@ -161,6 +171,16 @@
 					validator: function (chrs, maskset, pos, strict, opts) {
 						var frontValue = opts.getFrontValue(maskset.mask, maskset.buffer, opts);
 						if (frontValue.indexOf(opts.placeholder[0]) !== -1) frontValue = "01" + opts.separator;
+						if(chrs.charAt(0) == '1'){
+							var secondCharRgxp = new RegExp("[3-9]");
+							if(secondCharRgxp.test(chrs.charAt(1))){
+								chrs = '10';
+								return maskset.buffer[pos] = "0",
+								pos++, {
+									pos: pos
+								};
+							}
+						}
 						var isValid = opts.regex.val2(opts.separator).test(frontValue + chrs);
 						if (!strict && !isValid) {
 							if (chrs.charAt(1) === opts.separator || "-./".indexOf(chrs.charAt(1)) !== -1) {