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