15位⾝份证转18位
//15位转18位
functionC15ToC18(c15){
varcId;
if(==15){
pattern=/^d{15}$/;
if((c15)==null){
//alert("15位⾝份证号码必须为数字!")
return;
}
if(!isdate("19"+ing(6,8),ing(8,10),ing(10,12))){
//alert("⾝份证号码中所含⽇期不正确")
return;
}
cId=ing(0,6)+"19"+ing(6,15);
(cId)
varstrJiaoYan=["1","0","X","9","8","7","6","5","4","3","2"];
varintQuan=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
varintTemp=0;
for(i=0;i<;i++)
intTemp+=cId[i]*intQuan[i];
(intTemp)
intTemp%=11;
cId+=strJiaoYan[intTemp];
returncId;
}
return;
}
//检查年⽉⽇是否是合法⽇期
functionisdate(intYear,intMonth,intDay){
if(isNaN(intYear)||isNaN(intMonth)||isNaN(intDay))returnfal;
if(intMonth>12||intMonth<1)returnfal;
if(intDay<1||intDay>31)returnfal;
if((intMonth==4||intMonth==6||intMonth==9||intMonth==11)&&(intDay>30))returnfal;
if(intMonth==2){
if(intDay>29)returnfal;
if((((intYear%100==0)&&(intYear%400!=0))||(intYear%4!=0))&&(intDay>28))returnfal;
}
returntrue;
}
本文发布于:2022-11-13 14:54:07,感谢您对本站的认可!
本文链接:http://www.wtabcd.cn/fanwen/fan/88/11645.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |