身份证号合法性验证

//是否满18岁
function in18(birthYear,birthMonth,birthDay) {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() +1;
var day = now.getDate();
var age = year - birthYear;
var count = 0;
if(age<18){
count ++ ;
};
if(age == 18){
if(birthMonth > month){
count ++ ;
}else if(birthMonth == month){
if(birthDay > day){
count ++ ;
}
};
};
return count;
}

 

细校验(带平年、闰年、31天的月份、2月的天数,以及1920以后的人等的)

/^[1-9]\d{5}((((19|[2-9][0-9])\d{2})(0?[13578]|1[02])(0?[1-9]|[12][0-9]|3[01]))|(((19|[2-9][0-9])\d{2})(0?[13456789]|1[012])(0?[1-9]|[12][0-9]|30))|(((19|[2-9][0-9])\d{2})0?2(0?[1-9]|1[0-9]|2[0-8]))|(((1[6-9]|[2-9][0-9])(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))0?229))\d{3}[0-9Xx]$/;

posted on 2018-11-15 10:50  幻雪奇缘  阅读(791)  评论(0编辑  收藏  举报

导航