//是否满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]$/;
来源:oschina
链接:https://my.oschina.net/u/4255371/blog/3751078