Asp.net| Tips
<%@ Page language= "C #" codebehind= "CordBirthday.aspx.cs" autoeventwireup= "false" inherits= " CodeDatum.birthday.CordBirthday "%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>CordBirthday</title>
<meta name= "generator" content= "Microsoft Visual Studio. NET 7.1" >
<meta name= "Code_language" content= "C #" >
<meta name= "vs_defaultClientScript" content= "JavaScript" >
<meta name= "vs_targetschema" content= "http://schemas.microsoft.com/intellisense/ie5" >
<script language= "JavaScript" >
Function Showbirthday (val)
{
var Birthdayvalue;
if (15==val.length)
{///15-digit ID number
Birthdayvalue = Val.charat (6) +val.charat (7);
if (parseint (birthdayvalue) <10)
{
Birthdayvalue = ' +birthdayvalue ';
}
Else
{
Birthdayvalue = ' +birthdayvalue ';
}
Birthdayvalue=birthdayvalue+ '-' +val.charat (8) +val.charat (9) + '-' +val.charat (a) +val.charat (11);
if (parseint (Val.charat)/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 number
Birthdayvalue=val.charat (6) +val.charat (7) +val.charat (8) +val.charat (9) + '-' +val.charat (a) +val.charat (11)
+ '-' +val.charat (a) +val.charat (13);
if (parseint (Val.charat)/2 *2!=val.charat (16))
document.all.sex.value= ' Male ';
Else
document.all.sex.value= ' female ';
if (Val.charat ()!=idcard (Val))
{
Document.all.idcard.style.backgroundcolor= ' #ffc8c8 ';
}
Else
{
document.all.idcard.style.backgroundcolor= ' White ';
}
Document.all.birthday.value=birthdayvalue;
}
}
18-digit ID number, last check.
function Idcard (Num)
{
if (num.length!=18)
return false;
var x=0;
var y= ';
for (i=18;i>=2;i--)
x = x + (square (2, (i-1))%11) *parseint (Num.charat (19-i-1));
x%=11;
Y=12-x;
if (x==0)
y= ' 1 ';
if (x==1)
y= ' 0 ';
if (x==2)
y= ' X ';
return y;
}
Get y-square of X
function Square (x,y)
{
var I=1;
for (j=1;j<=y;j++)
I*=x;
return i;
}
</script>
</HEAD>
<body ms_positioning= "GridLayout" >
<form id= "Form1" method= "POST" runat= "Server" >
<table align= "center" >
<tr>
<TD align= "center" > ID: <input type= "text" name= "Idcard" id= "Idcard" ></td>
</tr>
<tr>
<TD align= "Center" > Gender: <input type= "text" name= "sex" id= "Sex" ></td>
</tr>
<tr>
<TD align= "center" > Birthday: <input type= "text" name= "Birthday" id= "Birthday" ></td>
</tr>
<tr>
<TD align= "center" ><input type= "button" value= "OK" ></td>
</tr>
</table>
</form>
</body>
</HTML>