小屁孩归来
/**
* 2
8.根据身份证号码测算性别
* 男性返回M,女性返回F
*
*/
Validates.getSexByChinaID=function (idno) {
if (this.checkChinaID(idno)) {
if (idno.length == 15) {
var sign = idno.substring(14, 15);
if (Validates.isLegalString(sign, "13579")) {
return "M";
} else {
return "F";
}
} else {
var sign = idno.substring(16, 17);
if (Validates.isLegalString(sign, "13579")) {
return "M";
} else {
return "F";
}
}
}
return "";
}
/**
*
* 29A.根据身份证号码测算出生日期
* 参数为身份证号码
* 返回出生日期的字符串,格式为"yyyy-mm-dd"
*/
Validates.getBirthdayByChinaID =function(idno) {
if (Validates.checkChinaID(idno)) {
if (idno.length == 15) {
var substr = idno.substring(6, 12);
return Validates.dateObjStandardFmt(substr);
} else {
var substr = idno.substring(6, 14);
return Validates.dateObjStandardFmt(substr);
}
}
return "";
}
/**
*
* 29B.根据身份证号码测算年龄
* 参数为身份证号码
* 返回出生日期的字符串,格式为"yyyy-mm-dd"
*/
Validates.GetAgeByBrithday =function (birthday,date){
var age=-1;
var today=date || new Date();
var todayYear=today.getFullYear();
var todayMonth=today.getMonth()+1;
var todayDay=today.getDate();
var birthday=new Date(birthday);
birthdayYear=birthday.getFullYear();
birthdayMonth=birthday.getMonth()+1;
birthdayDay=birthday.getDate();
if(todayYear-birthdayYear=0){
age = (todayYear - birthdayYear);
}else{
age = (todayYear - birthdayYear) - 1;
}
}
}
return age*1;
}
糖糖
搜吧,百度的