Get people's age and gender through their ID number

Source: Internet
Author: User

Get the person's age and gender by ID number:
ID card can identify a person's information, the following describes how to use JS through the ID card number to obtain the age and gender of the parties.
The code example is as follows:

<!DOCTYPE HTML><HTML><Head><MetaCharSet= "Utf-8"><Metaname= "Author"content= "http://www.softwhy.com/" /><title>Ant Tribe</title><Scripttype= "Text/javascript"> functionDiscricard (Uusercard) {uusercard.substring (6,Ten)+"-"+uusercard.substring (Ten, A)+"-"+uusercard.substring ( A, -); //Get Sex  if(parseint (Uusercard.substr ( -,1))%2==1) {alert ("male"); //is the man executes the code ...  }   Else{alert ("female"); //it's a woman. Execute code ...  }   //Get Age  varmydate= NewDate (); varMonth=Mydate.getmonth ()+ 1; var Day=mydate.getdate (); var Age=mydate.getfullyear ()-uusercard.substring (6, Ten) - 1; if(Uusercard.substring (Ten, A)<Month||uusercard.substring (Ten, A)==Month&&uusercard.substring ( A, -)<=Day ) { Age++;   } alert (age); //Age} window.onload=function(){  vartxt=document.getElementById ("txt"); varBT=document.getElementById ("BT"); Bt.onclick=function() {Discricard (txt.value);}}</Script></Head><Body><inputtype= "text"ID= "txt" /><inputtype= "button"value= "Click to get Info"ID= "BT" /></Body></HTML>


related reading:
1.substring () function can refer to the >javascript () method section of the
2.parseint () function can refer to a chapter.  
3.substr () function can refer to chapter.  
4.getmonth () function can refer to section.  
5.getdate () function can refer to section.  
6.getfullyear () function can refer to section.  

The original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=10786

For more information, refer to: http://www.softwhy.com/javascript/

Get people's age and gender through their ID number

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.