Sfoglia il codice sorgente

身份证校验说明

luolei 5 anni fa
parent
commit
7a20404ca6
1 ha cambiato i file con 18 aggiunte e 2 eliminazioni
  1. 18 2
      src/utils/tools.js

+ 18 - 2
src/utils/tools.js

@@ -110,9 +110,25 @@ const patt = /\$\{[^\]]+\}/g;
 // 手机号验证
 const phoneTest = /^[1]([3-9])[0-9]{9}$/;
 //身份证验证
-const identify =/(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/;
+/**15位
+ * [1-9]\d{5}                  前六位地区,非0打头    
+ * \d{2}                       出生年份后两位00-99
+ * ((0[1-9])|(10|11|12))       月份,01-12月
+ * (([0-2][1-9])|10|20|30|31)  日期,01-31天
+ * \d{2}[0-9Xx]                顺序码两位,一位校验码最后一位数字或者大小写X
+ */
+/**18位
+ * 
+ * 
+ * [1-9]\d{5}                 前六位地区,非0打头
+ * (18|19|([23]\d))\d{2}      出身年份,覆盖范围为 1800-3999 年
+ * ((0[1-9])|(10|11|12))      月份,01-12月
+ * (([0-2][1-9])|10|20|30|31) 日期,01-31天
+ * \d{3}[0-9Xx]:              顺序码三位, 一位校验码数字或者大小写X
+ */
+const identify = /(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$)|(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)/;
 //只能是数字和字母
-const jgpattern =/^[A-Za-z0-9]+$/;
+const jgpattern = /^[A-Za-z0-9]+$/;
 
 const getAllStr = (allData) =>{//获取界面数据,拼接字符串
   // console.log(allData,777777)