No more words write down a template ID phone email
'// vertifyQuestionnaire() {let message = null; let phone_reg = /^1[345789]\d{9}$/; let mail_reg = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; // let _IDRe18 = /^[1-9]\d{5}(? :18|19|20)\d{2}(? : 0 [1-9] (| | | 10 11 12)? :0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/; let _IDre15 = /^[1-9]\d{7}(? :0\d|10|11|12)(? :0[1-9]|[1-2][\d]|30|31)\d{3}$/; if (! This.patientgender) {message = "Please select your gender "; } else if (! This.patientname) {message = "Please enter your name "; } else if (! This.patientphone) {message = "Please fill in your phone number "; } else if (! This.patientemail) {message = "Please enter your email address "; } else if (! This.patientidcard) {message = "Please enter your ID card "; } else if (! This. CheckHospital) {message = "Please fill in your checkHospital "; } else { if (! Phone_reg. test(this.patientPhone)) message = "Wrong phone number "; if (! Mail_reg. test(this.patientEmail)) message = "Mailbox input error "; If (_IDRe18. Test (enclosing patientIDCard) | | _IDre15. Test (enclosing patientIDCard)) {the console. The log (" by "); } else {message = "id format error "; } } return message; },Copy the code
The ID card is divided into 18 and 15 digits.
Regular matching id divided into 18 and 15, first write regular before we understand the structure of the id number 18 areas: (1-6] [[1-9] | 50) \ d {4} / / added in chongqing area 50 years ago two: 18 19 | | (20) 1800-2399 after the two: \ d {2} : ((0 [1-9]) in 12) | | | 10 11 days: (([0-2] [1-9]) 10 20 | | | | 30 31) leap year cannot ban 29 + three sequence code: \ d {3} check code: [0-9xx] // Verify 18-bit ID card let _IDRe18 = / ^ ([1-6] [1-9] 50) | \ d {4} (18 19 20) | | \ d {2} (10 (0 [1-9]) | | | 11 12) (([0-2] [1-9]) 10 20 | | | | 30 31) \ d {3} [xx] 0-9 / id number in the structure of the 15: \ [1-6 \] \ [1-9 \] \ \ d {4} after only two years: \ \ d {2} in: ((0 \ [1-9 \]) | | | 10 11 days: (12) (\ [0 to 2 \] \ [1-9 \]) 10 20 | | | | 30 31) leap year cannot ban 29 + three sequence code: \\d{3} // Check 15-bit id card let \_IDRe15 = /^(\[1-6\]\[1-9\]|50)\\d{4}\\d{2}((0\[1-9\])|10|11|12)((\[0-2\]\[1-9\])|10|20|30|31)\\d{3}/