国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

ASP.NET技巧:根據身份證判斷性別和生日

2024-07-10 13:09:39
字體:
來源:轉載
供稿:網友

<%@ 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">性&nbsp;&nbsp;&nbsp;&nbsp;別:<input type="text" name="sex" id="sex"></td>
    </tr>
    <tr>
     <td align="center">生&nbsp;&nbsp;&nbsp;&nbsp;日:<input type="text" name="birthday" id="birthday"></td>
    </tr>
    <tr>
     <td align="center"><input type="button" value="ok"></td>
    </tr>
   </table>
  </form>
 </body>
</html>

中國最大的web開發資源網站及技術社區,
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 广丰县| 抚远县| 托克托县| 桂东县| 安溪县| 石棉县| 眉山市| 颍上县| 太谷县| 沙湾县| 上犹县| 盐池县| 漯河市| 博客| 科技| 枣强县| 正定县| 永泰县| 新巴尔虎左旗| 咸宁市| 巴中市| 姜堰市| 安丘市| 鸡西市| 航空| 通海县| 茂名市| 九台市| 静宁县| 田林县| 故城县| 定陶县| 赞皇县| 岱山县| 黄冈市| 施甸县| 民县| 滁州市| 凌海市| 龙陵县| 沭阳县|