PageSourceSearch

https://ws.static.mingyihui.net/js/check.js?v=20160924

js mingyihui.net collected 2026-10-01 07:34:08 UTC 7,201 bytes, 184 lines download raw bytes

1/**
2 * Created by Administrator on 2017/9/12.
3 */
4
5
6
7/**
8 * 验证身份证号
9 * @param idcard
10 * @param status true 不验证是否有重复身份证
11 * @returns {*}
12 */
13
14function checkIdcard(idcard,status) {
15    var area = {11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西",
16        37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃",
17        63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外"}
18    var idcard, Y, JYM;
19    var S, M;
20    var idcard_array = new Array();
21    idcard_array = idcard.split("");
22    var info=false;
23    //地区检验
24    if (area[parseInt(idcard.substr(0, 2))] == null) {
25        //console.log('地区检验失败');
26        info=false;
27    }
28    //身份号码位数及格式检验
29    switch (idcard.length) {
30        case 15:
31            if ((parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0 || ((parseInt(idcard.substr(6, 2)) + 1900) % 100 == 0 && (parseInt(idcard.substr(6, 2)) + 1900) % 4 == 0)) {
32                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}$/;
33                //测试出生日期的合法性
34            } else {
35                ereg = /^[1-9][0-9]{5}[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}$/;
36                //测试出生日期的合法性
37            }
38
39            if (ereg.test(idcard)) {
40                info=true;
41            } else {
42                info=false;
43            }
44            break;
45        case 18:
46            //console.log('18位身份证');
47            //18位身份号码检测
48            //出生日期的合法性检查
49            //闰年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))
50            //平年月日:((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))
51            if (parseInt(idcard.substr(6, 4)) % 4 == 0 || (parseInt(idcard.substr(6, 4)) % 100 == 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
52                //ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;
53                ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|[1-2][0-9]))[0-9]{3}[0-9Xx]$/;
54                //闰年出生日期的合法性正则表达式
55                //console.log('闰年');
56            } else {
57                //console.log('平年');
58                //ereg = /^[1-9][0-9]{5}19[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;
59                ereg = /^[1-9][0-9]{5}(19|20)[0-9]{2}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|3[0-1])|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|02(0[1-9]|1[0-9]|2[0-8]))[0-9]{3}[0-9Xx]$/;
60                //平年出生日期的合法性正则表达式
61            }
62            //console.log(ereg);
63            if (ereg.test(idcard)) {//测试出生日期的合法性
64
65                //计算校验位
66                S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 + (parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9
67                + (parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 + (parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5
68                + (parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 + (parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4
69                + (parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 + parseInt(idcard_array[7]) * 1 + parseInt(idcard_array[8]) * 6
70                + parseInt(idcard_array[9]) * 3;
71                Y = S % 11;
72                M = "F";
73                JYM = "10X98765432";
74                M = JYM.substr(Y, 1);//判断校验位
75                if (M == idcard_array[17].toUpperCase()) {
76                    info=true; //检测ID的校验位
77                } else {
78                    //console.log('校验位失败');
79                    info=false;
80                }
81            } else {
82                //console.log('正则失败');
83                info=false;
84            }
85            break;
86        default:
87            //console.log('长度不满足');
88            info=false;
89            break;
90    }
91    if(!info){
92        return '请输入正确的身份证号';
93    }else{
94        if(status==true){
95            return true;
96        }else{
97            var tmsg;
98            $.ajaxSetup({cache: false,async : false});
99            $.post(MYH_URL+"/api_check.php?act=checkIdcard&idcard="+idcard, function(msg){
100                tmsg=msg;
101            });
102            if(tmsg==1){
103                return true;
104            }else{
105                return tmsg;
106            }
107            return '请输入正确的身份证号';
108        }
109
110    }
111}
112
113/**
114 * 检验手机号是否可以注册
115 */
116function checkPhone(phone){
117    var tmsg='请输入正确手机号';
118    if (!isPhone(phone)){
119        return '请输入正确手机号';
120    }else{
121        //手机号重复
122        $.ajaxSetup({cache: false,async : false});
123        $.post(MYH_URL+"/api_check.php?act=pcheck&phone="+phone, function(msg){
124            tmsg=msg;
125        });
126        if(tmsg==1){
127            return true;
128        }else{
129            return tmsg;
130        }
131    }
132}
133
134/**
135 * 校验手机号
136 */
137function isPhone(s){
138    //var patrn=/^(\w){4,20}$/;
139    var patrn=/^(13[0-9]|14[0-9]|15[0-9]|17[0-9]|18[0-9])\d{8}$/i;
140    if (!patrn.exec(s)) return false
141    return true;
142}
143
144function checkRegName(name){
145    var pattern = /^[\u4E00-\u9FA5]{2,5}$/;
146    if(pattern.test(name)){
147        return true;
148    }else{
149        return "姓名格式不正确";
150    }
151}
152
153function checkPassword(password){
154    if(password==''){
155        return "请输入密码,6-16位英文或数字!";
156    }
157    var patrn=/^(\w){6,16}$/;
158    if (!patrn.exec(password)){
159        return "请输入密码,6-16位英文或数字!";
160    }else{
161        return true;
162    }
163}
164
165function sendPhoneCode(phone,imgcode){
166    var tmsg;
167    $.ajaxSetup({cache: false,async : false});
168    $.ajax({
169        url: PASSPROT_URL + "/api_new_captacha.php?mode=5&phone=" + phone + "&imgcode=" + imgcode,
170        type: 'get',
171        xhrFields: {
172            withCredentials: true
173        },
174        crossDomain: true,
175        success: function (msg) {
176            if(msg==1){
177                tmsg=true;
178            }else{
179                tmsg=msg;
180            }
181        }
182    })
183    return tmsg;
184}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.