Use the ID card number to obtain the JS Code of the birth date and gender.
Source: Internet
Author: User
// ID card verification and birthday Code
Copy code The Code is as follows: <script language = "JavaScript">
Function showbirthday (VAL)
{
VaR birthdayvalue;
If (15 = Val. length)
{// 15-digit ID card number
Birthdayvalue = Val. charat (6) + val. charat (7 );
If (parseint (birthdayvalue) <10)
{
Birthdayvalue = '20' + birthdayvalue;
}
Else
{
Birthdayvalue = '19' + birthdayvalue;
}
Birthdayvalue = birthdayvalue + '-' + val. charat (8) + val. charat (9) + '-' + val. charat (10) + val. charat (11 );
If (parseint (Val. charat (14)/2) * 2! = Val. charat (14 ))
Document. All. Sex. value = 'male ';
Else
Document. All. Sex. value = 'female ';
Document. All. Birthday. value = birthdayvalue;
}
If (18 = Val. length)
{// 18-digit ID card number
Birthdayvalue = Val. charat (6) + val. charat (7) + val. charat (8) + val. charat (9) + '-' + val. charat (10) + val. charat (11) + '-' + val. charat (12) + val. charat (13 );
If (parseint (Val. charat (16)/2) * 2! = Val. charat (16 ))
Document. All. Sex. value = 'male ';
Else
Document. All. Sex. value = 'female ';
If (Val. charat (17 )! = Idcard (VAL ))
{
Document. All. idcard. style. backgroundcolor = '# ffc8c8 ';
}
Else
{
Document. All. idcard. style. backgroundcolor = 'white ';
}
Document. All. Birthday. value = birthdayvalue;
}
}
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.