<%@ 페이지 언어="c#" Codebehind="CordBirthday.aspx.cs" AutoEventWireup="false" Inherits="CodeDatum.birthday.CordBirthday" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<헤드>
<title>코드생일</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 ">
<스크립트 언어="자바스크립트">
함수 showBirthday(val)
{
var 생일값;
if(15==val.length)
{ //15位身份证号码
birthdayValue = val.charAt(6)+val.charAt(7);
if(parseInt(생일값)<10)
{
birthdayValue = '20'+생일값;
}
또 다른
{
birthdayValue = '19'+생일값;
}
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='전체';
또 다른
document.all.sex.value='여자';
document.all.birthday.value=생일값;
}
if(18==val.length)
{ //18位身份证号码
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='전체';
또 다른
document.all.sex.value='여자';
if(val.charAt(17)!=IDCard(val))
{
document.all.idCard.style.BackgroundColor='#ffc8c8';
}
또 다른
{
document.all.idCard.style.BackgroundColor='흰색';
}
document.all.birthday.value=생일값;
}
}
// 18位身份证号最后一位校验
기능 IDCard(Num)
{
if (Num.length!=18)
거짓을 반환;
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;
만약 (x==0)
y='1';
만약 (x==1)
y='0';
만약 (x==2)
y='X';
y를 반환;
}
// 求得xy次方
함수 square(x,y)
{
var i=1;
(j=1;j<=y;j++)의 경우
나*=x;
내가 반환;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="서버">
<테이블 정렬="가운데">
<tr>
<td align="center">정보:<input type="text" name="idCard" id="idCard"></td>
</tr>
<tr>
<td align="center">성 别:<input type="text" name="sex" id="sex"></td>
</tr>
<tr>
<td align="center">生 日:<input type="text" name="생일" id="생일"></td>
</tr>
<tr>
<td align="center"><input type="button" onclick="showBirthday(document.all.idCard.value)" value="OK"></td>
</tr>
</table>
</form>
</body>
</HTML>