ソースを参照

Merge branch '4.x' of https://github.com/RobinHerbots/Inputmask into 4.x

Robin Herbots 8 年 前
コミット
b83a3d826f
2 ファイル変更23 行追加3 行削除
  1. 3 3
      README.md
  2. 20 0
      js/inputmask.date.extensions.js

+ 3 - 3
README.md

@@ -724,14 +724,14 @@ Inputmask({ mask: "9{*}").mask(selector);
 Use a regular expression as a mask
 
 ```
-Inputmask({ regex: "[0-9]*").mask(selector);
+Inputmask({ regex: "[0-9]*" }).mask(selector);
 ```
 
 When using shorthands be aware that you need to double escape or use String.raw with a string literal.
 ```
-Inputmask({ regex: "\\d*").mask(selector);  
+Inputmask({ regex: "\\d*" }).mask(selector);
 ~  
-Inputmask({ regex: String.raw`\d*`).mask(selector);
+Inputmask({ regex: String.raw`\d*` }).mask(selector);
 ```
 
 ### oncomplete

+ 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) {