661 lines
26 KiB
Plaintext
661 lines
26 KiB
Plaintext
@{Layout = null; }
|
||
<!doctype html>
|
||
<html>
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>个人信息录入</title>
|
||
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
|
||
<link href="../css/mui.min.css" rel="stylesheet" />
|
||
<link rel="stylesheet" href="../css/bootstrap.min.css" />
|
||
<link href="../Content/bootstrap.css" rel="stylesheet">
|
||
<!--css样式-->
|
||
<style type="text/css">
|
||
|
||
body, html {
|
||
width: 100%;
|
||
height: 100%;
|
||
position: relative;
|
||
background: #FFFFFF;
|
||
font-size: 14px;
|
||
}
|
||
/*主体*/
|
||
.mui-content {
|
||
width: 100%;
|
||
height: auto;
|
||
padding: 18% 10% 15% 5%;
|
||
background: #FFFFFF;
|
||
}
|
||
|
||
.mui-input-row {
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
.mui-input-row label {
|
||
text-align: right;
|
||
width: 35%;
|
||
line-height: 20px;
|
||
padding: 11px 10px;
|
||
}
|
||
|
||
.mui-input-row label ~ input, .mui-input-row label ~ select, .mui-input-row label ~ textarea {
|
||
border: 1px solid rgba(0,0,0,0.2);
|
||
padding-left: 8px;
|
||
font-size: 14px;
|
||
width: 64%;
|
||
}
|
||
|
||
#codeBtn {
|
||
position: absolute;
|
||
right: 3px;
|
||
top: 3px;
|
||
padding: 6px 0;
|
||
width: 27%;
|
||
color: #fff;
|
||
}
|
||
|
||
.acc_img {
|
||
position: relative;
|
||
width: 60%;
|
||
height: 100px;
|
||
margin: auto;
|
||
}
|
||
|
||
#sss, #acc_sc {
|
||
position: absolute;
|
||
width: 100%;
|
||
height: 100%;
|
||
z-index: 2;
|
||
border: 1px solid #EFEFF4;
|
||
border-radius: 5px;
|
||
text-align: center;
|
||
line-height: 100px;
|
||
position: absolute;
|
||
z-index: 1;
|
||
}
|
||
|
||
#upfile {
|
||
opacity: 0;
|
||
position: absolute;
|
||
width: 100%;
|
||
height: 100%;
|
||
z-index: 3;
|
||
}
|
||
|
||
#imgbox {
|
||
width: 100%;
|
||
height: 100px;
|
||
border: 1px solid #EFEFF4;
|
||
border-radius: 5px;
|
||
text-align: center;
|
||
line-height: 100px;
|
||
position: absolute;
|
||
z-index: 1;
|
||
}
|
||
|
||
#img0 {
|
||
width: 100%;
|
||
height: 100%;
|
||
border-radius: 5px;
|
||
position: absolute;
|
||
z-index: 3;
|
||
left: 0;
|
||
}
|
||
/*按钮*/
|
||
.mui-bar {
|
||
-webkit-box-shadow: none;
|
||
box-shadow: none;
|
||
height: 40px;
|
||
}
|
||
|
||
#submitBtn {
|
||
position: absolute;
|
||
height: 100%;
|
||
border-color: #007aff;
|
||
border-radius: 0;
|
||
background: #007aff;
|
||
color: #FFFFFF;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<!--页面主体-->
|
||
<div class="mui-content">
|
||
<form id="dataForm">
|
||
<div class="mui-input-row">
|
||
<label>姓名:</label>
|
||
<input type="text" class="mui-input-clear" placeholder="姓名" name="name" value="" id="name">
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<label>身份证:</label>
|
||
<input type="text" class="mui-input-clear" placeholder="身份证" name="ident" id="userident" maxlength="18" value="">
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<label>出生日期:</label>
|
||
<input type="text" class="mui-input-clear" placeholder="出生日期" name="birth" id="userbirth" value="">
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<label>所属单位:</label>
|
||
<input type="text" class="mui-input-clear" placeholder="所属单位" name="unit" value="" id="unit">
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<label>所属人群:</label>
|
||
<select class="mui-select" name="crowd_id" id="test_type">
|
||
<option class="">请选择所属人群</option>
|
||
</select>
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<label>手机号码:</label>
|
||
<input type="number" class="mui-input-clear" placeholder="手机号码" name="phone" maxlength="11" value="" id="phone">
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<label></label>
|
||
<input type="number" class="mui-input-clear" placeholder="短信验证码" name="yzm">
|
||
<button class="btn mui-btn-blue" type="button" id="codeBtn" onclick="fnShowCode()">获取验证码</button>
|
||
</div>
|
||
<div class="mui-input-row">
|
||
<div class="acc_img">
|
||
<div id="sss">
|
||
<img class="acc_imgin" src="" id="img0" style="display: none;">
|
||
<p id="imgText">上传驾驶证照片</p>
|
||
</div>
|
||
<input type="file" name="upfile" id="upfile" />
|
||
<!--<p class="ph09 ">注:身份证上的所有信息清晰可见,必须能看清证件号。照片需免冠,建议未化妆。手持证件人的五官清晰可见。照片内容真实有效。不得做任何修改。支持jpg、jpeg、bmp、gif格式照片。大小不超过5M</p>-->
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mui-input-row">
|
||
<label>推荐码:</label>
|
||
<input type="text" class="mui-input-clear" placeholder="推荐码" name="referee" id="TJM" value="@ViewBag.remark">
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal fade" id="loadingModal">
|
||
<div style="position: relative;top: 30%;">
|
||
<div style="width: 100%;background: transparent;text-align: center;">
|
||
<img src="../Images/5-1503130Q911.gif" style="margin: 25px 0;width: 7%;" />
|
||
</div>
|
||
</div>
|
||
<h5 style="position: relative;top: 30%;color:#fff;text-align: center;font-size: 16px;margin: 15px 0 ;"> <strong>正在保存...请稍等!</strong> </h5>
|
||
</div>
|
||
<nav class="mui-bar mui-bar-tab">
|
||
<input type="button" class="mui-btn mui-btn-block mui-btn-primary" value="提交" id="submitBtn" />
|
||
</nav>
|
||
<!--js内容-->
|
||
<script src="../js/mui.min.js"></script>
|
||
<script type="text/javascript" src="../js/common.js"></script>
|
||
<script type="text/javascript" src="../js/jquery-2.1.0.js"></script>
|
||
<script type="text/javascript" src="../js/ajaxfileupload.js"></script>
|
||
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
|
||
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
|
||
<script type="text/javascript">
|
||
var crowdList, yzmid;
|
||
wx.config({
|
||
debug: false, //是否调试,true,会弹窗
|
||
appId: '@dccdc.Common.Global.InfectionAppId', //得到这个东西,首先必须有一个公众号,或者企业号,如果已经拥有了,你可以就知道AppId在哪里了。
|
||
timestamp: '@ViewBag.timeStamp',//生成签名的时间戳,随机数,之后会用这个生成一个签名
|
||
nonceStr: '@ViewBag.nonceStr',//生成签名的随机串,随机串,之后会用这个生成一个签名
|
||
signature: '@ViewBag.signature',//这个就是签名了,在步骤4,我会详细讲解
|
||
jsApiList: [
|
||
'onMenuShareTimeline',
|
||
'onMenuShareAppMessage',
|
||
'onMenuShareQQ',
|
||
'onMenuShareWeibo',
|
||
'onMenuShareQZone'
|
||
]
|
||
});
|
||
|
||
wx.ready(function () {
|
||
wx.checkJsApi({
|
||
jsApiList: [
|
||
'onMenuShareTimeline',
|
||
'onMenuShareAppMessage',
|
||
'onMenuShareQQ',
|
||
'onMenuShareWeibo',
|
||
'onMenuShareQZone'
|
||
], // 需要检测的JS接口列表,所有JS接口列表见附录2,
|
||
success: function (res) {
|
||
// 以键值对的形式返回,可用的api值true,不可用为false
|
||
// 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
|
||
}
|
||
});
|
||
var shareUrl = 'http://oa.dcqcdc.com/dccdc/infection/tjfx2?id=@ViewBag.id&recommend=@ViewBag.recommend&name=@ViewBag.name';
|
||
var obj = {//朋友圈
|
||
title: '德城健康e路', // 分享标题
|
||
desc: '@ViewBag.name 邀请您参与德城区卡车司机健康促进项目!', // 分享描述
|
||
link: shareUrl, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
|
||
// 该链接是重定向链接,因为需要获取用户code,但是该链接又无法直接写微信获取code的链接,
|
||
// 所以需要点击后重新加载新的页面,来实现重定向,重新打开获取code的微信链接,实现获取用户信息的功能;
|
||
imgUrl: '@ViewBag.license', // 分享图标
|
||
fail: function (res) {
|
||
alert(JSON.stringify(res));
|
||
},
|
||
success: function (res) {
|
||
}
|
||
};
|
||
|
||
// 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口
|
||
wx.onMenuShareAppMessage(obj);
|
||
// 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
|
||
wx.onMenuShareTimeline(obj);
|
||
// 2.3 监听“分享到QQ”按钮点击、自定义分享内容及分享结果接口
|
||
wx.onMenuShareQQ(obj);
|
||
// 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口
|
||
wx.onMenuShareWeibo(obj);
|
||
// 2.5 监听“分享到QZone”按钮点击、自定义分享内容及分享接口
|
||
wx.onMenuShareQZone(obj);
|
||
});
|
||
|
||
window.onload = function () {
|
||
var tjm;
|
||
mui.init()
|
||
var url1 = "@Url.Action("GetAllIDNameIsQuestion")";/*serverurl + "/Infection/GetAllIDNameIsQuestion";*/
|
||
$.ajax(url1, {
|
||
data: {},
|
||
type: "post",
|
||
async:false,
|
||
dataType: "json",
|
||
success: function(data) {
|
||
if(data){
|
||
crowdList = data;
|
||
}
|
||
},
|
||
error: function(a, b, c) {
|
||
mui.toast("ajax传输失败2");
|
||
}
|
||
});
|
||
|
||
var url1 = "@Url.Action("GetDataListByUserID_OpenUserInfo")";/*serverurl + "/Infection/GetDataListByUserID_OpenUserInfo";*/
|
||
$.ajax(url1, {
|
||
data: {},
|
||
type: "post",
|
||
async:false,
|
||
dataType: "json",
|
||
success: function(data) {
|
||
var testTpye = document.getElementById("test_type");
|
||
for(var key in crowdList){
|
||
var op=document.createElement("option");// 新建OPTION (op)
|
||
op.setAttribute("value",crowdList[key].id);
|
||
if(data.length != 0 && data != null){
|
||
if(crowdList[key].id == data[0].crowd_id){
|
||
op.selected = true;
|
||
}
|
||
}
|
||
op.value = crowdList[key].id;
|
||
// 设置OPTION的 VALUE
|
||
op.appendChild(document.createTextNode(crowdList[key].name)); // 设置OPTION的 TEXT
|
||
testTpye.appendChild(op);
|
||
}
|
||
if(data.length != 0 && data != null){
|
||
|
||
var username = document.getElementById("name");
|
||
var userident = document.getElementById("userident");
|
||
var userbirth = document.getElementById("userbirth");
|
||
var userphone = document.getElementById("phone");
|
||
var userunit = document.getElementById("unit");
|
||
var usercrowd = document.getElementById("crowd");
|
||
var userpicture = document.getElementById("img0");
|
||
var userreferee = document.getElementById("TJM");
|
||
|
||
username.value = data[0].name;
|
||
userident.value = data[0].ident;
|
||
userbirth.value = data[0].birth;
|
||
userphone.value = data[0].phone;
|
||
userunit.value = data[0].unit;
|
||
userreferee.value = data[0].referee;
|
||
|
||
userpicture.src = "/dccdc" + data[0].license;
|
||
userpicture.style.display = "block";
|
||
// 审核通过时不能再修改这个画面
|
||
if (data[0].type == "1"&& @ViewBag.state == 0)
|
||
{
|
||
document.getElementById("submitBtn").disabled = true;
|
||
document.getElementById("TJM").disabled = true;
|
||
window.location.href = "@Url.Action("userInfo")";
|
||
}
|
||
}
|
||
},
|
||
error: function(a, b, c) {
|
||
mui.toast("ajax传输失败2");
|
||
}
|
||
});
|
||
$("#submitBtn")[0].addEventListener("click", function() {
|
||
var keyvalues = getForm2("dataForm");
|
||
//姓名
|
||
if(keyvalues["name"] == "" || keyvalues["name"].length == 0){
|
||
mui.toast("请填写姓名");
|
||
return;
|
||
}
|
||
|
||
//身份证号
|
||
if(keyvalues["ident"] == "" || keyvalues["ident"].length == 0){
|
||
mui.toast("请填写身份证号码");
|
||
return;
|
||
}
|
||
var Errors = checkIdcard(keyvalues["ident"])
|
||
if (Errors.length > 0 && Errors != null && Errors != "验证通过!") {
|
||
mui.toast(Errors);
|
||
return;
|
||
}
|
||
|
||
//出生日期
|
||
if(keyvalues["birth"] == "" || keyvalues["birth"].length == 0){
|
||
mui.toast("请填写出生日期");
|
||
return;
|
||
}
|
||
var ident = document.getElementById("userident");
|
||
keyvalues["sex"] = (parseInt(ident.value.substr(16, 1))% 2) != 1 ?2:1;
|
||
keyvalues["yzmid"] = yzmid;
|
||
//所属单位
|
||
if(keyvalues["unit"] == "" || keyvalues["unit"].length == 0){
|
||
mui.toast("请填写所属单位");
|
||
return;
|
||
}
|
||
|
||
//所属人群
|
||
if (keyvalues["crowd_id"] == "" || keyvalues["crowd_id"].length == 0 || keyvalues["crowd_id"] == "请选择所属人群") {
|
||
mui.toast("请填写所属人群");
|
||
return;
|
||
}
|
||
|
||
//手机号
|
||
if(keyvalues["phone"] == "" || keyvalues["phone"].length == 0){
|
||
mui.toast("请填写手机号码");
|
||
return;
|
||
}
|
||
|
||
//手机号
|
||
if(keyvalues["phone"].length != 11){
|
||
mui.toast("请填写正确手机号码");
|
||
return;
|
||
}
|
||
|
||
//验证码
|
||
if(keyvalues["yzm"].length == 0 || keyvalues["yzm"] == ""){
|
||
mui.toast("请填写验证码");
|
||
return;
|
||
}
|
||
var img0 = document.getElementById("img0");
|
||
var ImgObj = new Image();
|
||
ImgObj.src = img0.src.toString();
|
||
if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
|
||
|
||
} else {
|
||
mui.toast("请上传图片");
|
||
return;
|
||
}
|
||
//if(img0.src.toString().length == 0){
|
||
// var fileObj = document.getElementById("upfile").files[0]; // js 获取文件对象
|
||
// if (typeof (fileObj) == "undefined" || fileObj.size <= 0) {
|
||
// mui.toast("请上传图片");
|
||
// return;
|
||
// }
|
||
//}
|
||
keyvalues["license"] = img0.getAttribute("license");
|
||
|
||
|
||
var url1 = "@Url.Action("SaveData_OpenUserInfo")";/*serverurl + "/Infection/SaveData_OpenUserInfo";*/
|
||
ajaxFileUpload(url1,keyvalues);
|
||
})
|
||
|
||
//身份证获取出生日期
|
||
var ident = document.getElementById("userident");
|
||
ident.onblur = function (){
|
||
if (ident.value.length >= 15) {
|
||
//var date1 = ident.value.substring(6, 14);
|
||
//var year = date.substr(0, 3);
|
||
//var date2 = ident.value.substring(6, 14);
|
||
//var month = date2.substr(4, 6);
|
||
//var date3 = ident.value.substring(6, 14);
|
||
//var day = date3.substr(6, 8);
|
||
//var birth = year + month + day;
|
||
//doc.getElementById("userbirth").value = date1;
|
||
var birth = ident.value.substring(6, 14);
|
||
document.getElementById("userbirth").value = birth;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
$("#upfile").change(function() {
|
||
|
||
if (this.files && this.files[0]) {
|
||
var objUrl = getObjectURL(this.files[0]);
|
||
if (objUrl) {
|
||
$("#img0").attr("src", objUrl);
|
||
$("#upfile").click(function(e) {
|
||
$("#img0").attr("src", objUrl);
|
||
});
|
||
$("#img0").attr("license",1);
|
||
$("#img0").show();
|
||
$("#imgText").hide();
|
||
} else {
|
||
//IE下,使用滤镜
|
||
this.select();
|
||
var imgSrc = document.selection.createRange().text;
|
||
var localImagId = document.getElementById("sss");
|
||
//图片异常的捕捉,防止用户修改后缀来伪造图片
|
||
try {
|
||
preload.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = data;
|
||
} catch (e) {
|
||
this._error("filter error");
|
||
return;
|
||
}
|
||
this.img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src=\"" + data + "\")";
|
||
}
|
||
$("#img0").show();
|
||
}
|
||
});
|
||
//建立一個可存取到該file的url
|
||
function getObjectURL(file) {
|
||
var url = null;
|
||
if (window.createObjectURL != undefined) { // basic
|
||
url = window.createObjectURL(file);
|
||
} else if (window.URL != undefined) { // mozilla(firefox)
|
||
url = window.URL.createObjectURL(file);
|
||
} else if (window.webkitURL != undefined) { // webkit or chrome
|
||
url = window.webkitURL.createObjectURL(file);
|
||
}
|
||
return url;
|
||
}
|
||
var countdown=59;
|
||
function fnShowCode(){
|
||
var code = document.getElementById("code");
|
||
var codeBtn = document.getElementById("codeBtn");
|
||
var phone = document.getElementById("phone");
|
||
var url1 = "@Url.Action("getsjyzm")";/*serverurl + "/Infection/getsjyzm";*/
|
||
$.ajax(url1, {
|
||
data: {
|
||
Mobile:phone.value
|
||
},
|
||
type: "post",
|
||
dataType: "text",
|
||
success: function(data) {
|
||
if(data){
|
||
var item = JSON.parse(data);
|
||
yzmid = item["Message"];
|
||
}
|
||
},
|
||
error: function(a, b, c) {
|
||
mui.toast("ajax传输失败2");
|
||
}
|
||
})
|
||
if(!phone){
|
||
mui.toast("请输入手机号");
|
||
}
|
||
settime();
|
||
}
|
||
|
||
//构造一个倒计时函数叫settime
|
||
function settime(obj) {
|
||
//开始判断倒计时是否为0
|
||
if (countdown == '-1') {
|
||
$('#codeBtn').attr("disabled", false);
|
||
$('#codeBtn').css("background-color", "red");
|
||
$('#codeBtn').text("重新获取验证码");
|
||
countdown = 59;
|
||
} else {
|
||
$('#codeBtn').attr("disabled", true);
|
||
$('#codeBtn').css("background-color", "gray");
|
||
$('#codeBtn').text("重新发送"+countdown+"S");
|
||
countdown--;
|
||
setTimeout(function () {
|
||
settime()
|
||
}, 1000);//1s后执行settime()函数;
|
||
};
|
||
}
|
||
|
||
function ajaxFileUpload(url1,keyvalues){
|
||
$("#loadingModal").modal({ backdrop: "static", keyboard: false });
|
||
//$("#loadingModal").modal('show');
|
||
$.ajaxFileUpload({
|
||
url: url1, //用于文件上传的服务器端请求地址
|
||
data:keyvalues,
|
||
secureuri: false,
|
||
fileElementId: "upfile",
|
||
dataType: 'json',
|
||
success: function (data, status) {
|
||
mui.toast(data);
|
||
$("#loadingModal").modal('hide');
|
||
if (data == "修改成功!" || data == "保存成功!") {
|
||
WeixinJSBridge.call('closeWindow');
|
||
@*mui.openWindow({
|
||
url: '@Url.Action("userInfo")', //通过URL传参
|
||
id: 'userInfo'
|
||
})*@
|
||
} else {
|
||
if (data == "图片保存失败!")
|
||
{
|
||
$("#imgText").show();
|
||
$("#img0").hide();
|
||
}
|
||
}
|
||
},
|
||
error: function (data, status, e) {
|
||
$("#loadingModal").modal('hide');
|
||
alert(e);
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
function checkIdcard(idcard) {
|
||
//错误信息
|
||
var Errors = new Array("验证通过!", "身份证号码位数不对!", "身份证号码出生日期超出范围或含有非法字符!", "身份证号码校验错误!", "身份证地区非法!");
|
||
var area = {
|
||
11: "北京",
|
||
12: "天津",
|
||
13: "河北",
|
||
14: "山西",
|
||
15: "内蒙古",
|
||
21: "辽宁",
|
||
22: "吉林",
|
||
23: "黑龙江",
|
||
31: "上海",
|
||
32: "江苏",
|
||
33: "浙江",
|
||
34: "安徽",
|
||
35: "福建",
|
||
36: "江西",
|
||
37: "山东",
|
||
41: "河南",
|
||
42: "湖北",
|
||
43: "湖南",
|
||
44: "广东",
|
||
45: "广西",
|
||
46: "海南",
|
||
50: "重庆",
|
||
51: "四川",
|
||
52: "贵州",
|
||
53: "云南",
|
||
54: "西藏",
|
||
61: "陕西",
|
||
62: "甘肃",
|
||
63: "青海",
|
||
64: "宁夏",
|
||
65: "新疆",
|
||
71: "台湾",
|
||
81: "香港",
|
||
82: "澳门",
|
||
91: "国外"
|
||
}
|
||
var idcard, Y, JYM;
|
||
var S, M;
|
||
var idcard_array = new Array();
|
||
idcard_array = idcard.split("");
|
||
//地区检验
|
||
if (area[parseInt(idcard.substr(0, 2))] == null)
|
||
return Errors[4];
|
||
//身份证号码位数及格式检验
|
||
switch (idcard.length) {
|
||
case 15:
|
||
//15位身份证号码,出生日期的合法性检查
|
||
//闰年月日:((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]))
|
||
//平年月日:((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]))
|
||
if ((parseInt(idcard.substr(6, 2)) + 1900) % 400 == 0 ||
|
||
((parseInt(idcard.substr(6, 2)) + 1900) % 100 != 0 &&
|
||
(parseInt(idcard
|
||
.substr(6, 2)) +
|
||
1900) %
|
||
4 ==
|
||
0)) {
|
||
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}$/; //闰年出生日期的合法性正则表达式
|
||
} else {
|
||
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}$/; //平年出生日期的合法性正则表达式
|
||
}
|
||
|
||
|
||
if (ereg.test(idcard))
|
||
return Errors[0];
|
||
else
|
||
return Errors[2];
|
||
break;
|
||
case 18:
|
||
//18位身份证号码,出生日期的合法性检查
|
||
//闰年月日:((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]))
|
||
//平年月日:((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]))
|
||
if (parseInt(idcard.substr(6, 4)) % 400 == 0 ||
|
||
(parseInt(idcard.substr(6, 4)) % 100 != 0 && parseInt(idcard.substr(6, 4)) % 4 == 0)) {
|
||
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]$/; //闰年出生日期的合法性正则表达式
|
||
} else {
|
||
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]$/; //平年出生日期的合法性正则表达式
|
||
}
|
||
if (ereg.test(idcard)) {
|
||
|
||
|
||
//计算校验位
|
||
S = (parseInt(idcard_array[0]) + parseInt(idcard_array[10])) * 7 +
|
||
(parseInt(idcard_array[1]) + parseInt(idcard_array[11])) * 9 +
|
||
(parseInt(idcard_array[2]) + parseInt(idcard_array[12])) * 10 +
|
||
(parseInt(idcard_array[3]) + parseInt(idcard_array[13])) * 5 +
|
||
(parseInt(idcard_array[4]) + parseInt(idcard_array[14])) * 8 +
|
||
(parseInt(idcard_array[5]) + parseInt(idcard_array[15])) * 4 +
|
||
(parseInt(idcard_array[6]) + parseInt(idcard_array[16])) * 2 +
|
||
parseInt(idcard_array[7]) * 1 +
|
||
parseInt(idcard_array[8]) * 6 +
|
||
parseInt(idcard_array[9]) * 3;
|
||
Y = S % 11;
|
||
M = "F";
|
||
JYM = "10X98765432";
|
||
M = JYM.substr(Y, 1);
|
||
|
||
if (M == idcard_array[17]) //判断校验位
|
||
return Errors[0];
|
||
else
|
||
return Errors[3];
|
||
} else
|
||
return Errors[2];
|
||
break;
|
||
default:
|
||
return Errors[1];
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
</script>
|
||
</body>
|
||
</html> |