基於javascript實現根據社會安全號碼碼識別性別和年齡,社會安全號碼碼識別性別

來源:互聯網
上載者:User

基於javascript實現根據社會安全號碼碼識別性別和年齡,社會安全號碼碼識別性別

本文執行個體介紹了javascript實現根據社會安全號碼碼識別性別和年齡的詳細代碼,分享給大家供大家參考,具體內容如下

:

具體代碼:

<html><head><meta charset="gb2312"><title>jb51</title><script type="text/javascript"> function discriCard(UUserCard){  UUserCard.substring(6,10)+"-"+UUserCard.substring(10,12)+"-"+UUserCard.substring(12,14);  //擷取性別  if(parseInt(UUserCard.substr(16,1))%2==1)  {   alert("男");   //是男則執行代碼 ...  }  else  {   alert("女");   //是女則執行代碼 ...  }  //擷取年齡  var myDate = new Date();  var month = myDate.getMonth() + 1;  var day = myDate.getDate();  var age = myDate.getFullYear()-UUserCard.substring(6, 10) - 1;  if (UUserCard.substring(10,12)<month||UUserCard.substring(10,12)==month&&UUserCard.substring(12,14)<=day)  {   age++;  }  alert(age);  //年齡 age } window.onload=function(){ var txt=document.getElementById("txt"); var bt=document.getElementById("bt"); bt.onclick=function(){discriCard(txt.value);}}</script></head><body><input type="text" id="txt" /><input type="button" value="點擊擷取資訊" id="bt" /></body></html>

以上就是本文的全部內容,希望對大家學習javascript程式設計有所協助。

您可能感興趣的文章:
  • vbscript和javascript版的15位, 18位的社會安全號碼碼的驗證函式.以及根據身份證取省份,生日,性別
  • JS支援帶x社會安全號碼碼驗證函式
  • javascript或asp實現的判斷社會安全號碼碼是否正確兩種驗證方法
  • javascript 社會安全號碼碼驗證函式(可辨真偽,支援15或18位社會安全號碼)測試誤差為0
  • js 第二代社會安全號碼碼的驗證機制代碼
  • js簡單實現根據社會安全號碼碼識別性別年齡生日
  • js實現社會安全號碼碼驗證的簡單一實例
  • js實現二代社會安全號碼碼驗證詳解
  • 如何用javascriptRegex驗證社會安全號碼碼是否合法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.