123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- function IdentityCodeValid(code) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- let idcardTest = /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/
- if (!idcardTest.test(code)) {
- return false;
- } else {
- return true;
- }
- }
- function isPoneAvailable(poneInput) {
- var myreg = /^[1][3-9][0-9]{9}$/;
- if (!myreg.test(poneInput)) {
- return false;
- } else {
- return true;
- }
- }
- function getBirthdatByIdNo(iIdNo) {
- var tmpStr = "";
- iIdNo = iIdNo.replace(/^\s+|\s+$/g, "");
- if (iIdNo.length == 15) {
- tmpStr = iIdNo.substring(6, 12);
- tmpStr = "19" + tmpStr;
- tmpStr = tmpStr.substring(0, 4) + "/" + tmpStr.substring(4, 6) + "/" + tmpStr.substring(6)
- } else {
- tmpStr = iIdNo.substring(6, 14);
- tmpStr = tmpStr.substring(0, 4) + "/" + tmpStr.substring(4, 6) + "/" + tmpStr.substring(6)
- }
- return tmpStr;
- }
- function getSex(idcard) {
- let sex = ''
- if (parseInt(idcard.substr(16, 1)) % 2 == 1) {
- sex = '男'
- } else {
- sex = '女'
- }
- return sex
- }
- function authCode(str){
- let length = str.replace(/\s/g,"").length
- return length
- }
- module.exports = {
- IdentityCodeValid,
- isPoneAvailable,
- getBirthdatByIdNo,
- getSex,
- authCode
- }
|