Home > Web Front-end > JS Tutorial > body text

js simple implementation of identifying gender, age and birthday based on ID number_javascript skills

WBOY
Release: 2016-05-16 17:11:49
Original
1934 people have browsed it

JS code to identify gender, age, and birthday based on ID number:

Copy code The code is as follows:

function discriCard(){
//Get the input ID number
var UUserCard = "";
//Get the 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 you are a man, execute the code...
} else {
alert("Female");
//If you are a female, 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
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template