//获取出入日期及性别
function getBirthdatByIdNo() { var tmpStr = ""; var sexStr = 0; var iIdNo = $.trim($('#personIdCard').val()); if(isCardNo(iIdNo) == false) { alert("身份证号格式不正确"); return false; } if (iIdNo.length == 15) { tmpStr = iIdNo.substring(6, 12); tmpStr = "19" + tmpStr; tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6); sexStr = parseInt(iIdNo.substring(14, 1),10) % 2 ? 0 : 1; }else { tmpStr = iIdNo.substring(6, 14); tmpStr = tmpStr.substring(0, 4) + "-" + tmpStr.substring(4, 6) + "-" + tmpStr.substring(6); sexStr = parseInt(iIdNo.substring(17, 1),10) % 2 ? 0 : 1; } $('#birthday').datebox('setValue',tmpStr); if(sexStr == 0){ $("input:radio[name='personSex'][value='0']").attr('checked',true); }else if(sexStr == 1){ $("input:radio[name='personSex'][value='1']").attr('checked',true); } }
//验证身份证号
function isCardNo(card) { var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; return pattern.test(card); }