JS code to identify gender, age, and birthday based on ID number:
Copy the code code as follows:
function discriCard(){
//Get the input ID number
var UUserCard = "";
//Get date of birth
UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
//get gender
if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
alert("male");
//If it is a man, execute the code...
} else {
alert("female");
//If it is a woman, execute the code...
}
//get age
var myDate = new Date();
var month = myDate.getMonth() + 1;
var day = myDate.getDate();
var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;
if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {
age++;
}
alert(age);
//Age
}