Here we tell about the JQ according to the ID number of the birth date, age, gender, the need for students to refer to.
The code is as follows |
Copy Code |
Get input ID number var Uusercard = $ ("#UUserCard"). Val (); Get Birth date//uusercard.substring (6, +) + "-" + uusercard.substring (Ten) + "-" + uusercard.substring (12, 14); Get Gender if (parseint (Uusercard.substr (16, 1))% 2 = = 1) {//male} else {//female}//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 (Ten) < month | | Uusercard.substring (Ten) = = Month && uusercard.substring (<=) {age++;}//Age |
JS Code
Getbirthdayfromidcard:function (idcard) { var birthday = ""; if (idcard! = NULL && Idcard! = "") {if (Idcard.leng th = =) {birthday = "+idcard.substr" (6,6);} else if (idcard.length = =) {birthday = Idcard.substr (6,8);} Birthday = Birthday.replace (/(. { 4}) (. { 2})/, "$1-$2-");} return birthday; },
Instance
425125198808083000
Results
1988-08-08
JS get Birth date by ID number