How to use javascript to get the birthday, age, and gender of the client through the ID card number-javascript tutorial

Source: Internet
Author: User
The ID card can identify a person's information. The following describes how to use JavaScript to obtain the age and gender ID card of the person using the ID card number to identify a person's information, the following describes how to use JavaScript to obtain the age and gender of the client through the ID card number.

Script function IdCard (UUserCard, num) {if (num = 1) {// get birth date birth = UUserCard. substring (6, 10) + "-" + UUserCard. substring (10, 12) + "-" + UUserCard. substring (12, 14); return birth;} if (num = 2) {// obtain the gender if (parseInt (UUserCard. substr (16, 1) % 2 = 1) {// male return "male";} else {// female return "female ";}} if (num = 3) {// obtain the 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 ++;} return age ;}} alert (IdCard ('000000', 3); script

The following code is used to obtain the age and gender of a person using the ID card number.

The code example is as follows:

 
 Foot home

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.