<%@ 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位身份证号码
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='男';
else
document.all.sex.value='女';
document.all.birthday.value=birthdayvalue;
}
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='男';
else
document.all.sex.value='女';
if(val.charat(17)!=idcard(val))
{
document.all.idcard.style.backgroundcolor='#ffc8c8';
}
else
{
document.all.idcard.style.backgroundcolor='white';
}
document.all.birthday.value=birthdayvalue;
}
}
// 18位身份证号最后一位校验
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;
}
// 求得x的y次方
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">身份证:<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="birthday" id="birthday"></td>
</tr>
<tr>
<td align="center"><input type="button" value="ok"></td>
</tr>
</table>
</form>
</body>
</html>
新闻热点
疑难解答
图片精选