<!
根据身份证验证规则编写此小程序
>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>身份证规则计算器</title>
<style> /* This is a CSS style sheet: it adds style to the program output */
.output { font-weight: bold; } /* Calculated values in bold */
#IDnumber { text-decoration: underline; } /* For element with id="payment" */
th, td { vertical-align: top; } /* Don't center table cells */
</style>
</head>
<body>
<table>
<tr>当你的身份证号码隐藏年月的时候,你知道别人多少次能推测出你的真实号码么?</tr>
<tr><th>输入身份证号码(年月以任意字符或数字代替,不区分位数大小写X):</th>
</tr>
<tr><td>身份证号码:</td>
<td><input id="IDnumber" onchange="calculate();"></td>
<tr><th>点击计算:</th>
<td><button onclick="calculate();">计算</button></td></tr>
<tr><td>合法组合:</td>
<td><span class="output" id="showarea"></span></td></tr>
</table>
<script>
"use strict"; // Use ECMAScript 5 strict mode in browsers that support it
function calculate() {
// Look up the input and output elements in the document
//
showarea.innerHTML = "" ;
var tmpIDnumber = ElementById("IDnumber");
var IDnumber = String();
save(tmpIDnumber.value);
var yyyy = IDnumber.substring(6,10);
var idNumTOCk = "" ;
var day = 0 ;
var dayMax = 0;
var mm = 0 ;
var mmStr = "" ;
for(mm=1;mm<=12;mm++){
switch(mm){
case 1 :mmStr ="01";dayMax = 31 ; break;
case 2 :mmStr ="02";dayMax = isLeapYear(yyyy) ? 29 : 28 ; break;
case 3 :mmStr ="03";dayMax = 31 ; break;
case 4 :mmStr ="04";dayMax = 31 ; break;
case 5 :mmStr ="05";dayMax = 31 ; break;
case 6 :mmStr ="06";dayMax = 31 ; break;
case 7 :mmStr ="07";dayMax = 31 ; break;
case 8 :mmStr ="08";dayMax = 31 ; break;
case 9 :mmStr ="09";dayMax = 31 ; break;
case 10 :mmStr ="10";dayMax = 31 ; break;
case 11 :mmStr ="11";dayMax = 31 ; break;
case 12 :mmStr ="12";dayMax = 31 ; break;
default: dayMax = 31 ;
}
for(day = 1 ;day <= dayMax; day ++){
汪涵向欧弟道歉if(day<10){
idNumTOCk = IDnumber.substring(0, 10) + mmStr + "0" + day + IDnumber.substring(14, 18);
if(isValidate(idNumTOCk)){
//alert("========="+idNumTOCk);
showarea.innerHTML += idNumTOCk + " | " ;
}
}else{
idNumTOCk = IDnumber.substring(0, 10) + mmStr + day + IDnumber.substring(14, 18);
if(isValidate(idNumTOCk)){
//ValiCount++;
//alert("========="+idNumTOCk);
showarea.innerHTML += idNumTOCk + " | " ;
}
}
}
}
}
//判断闰年
function isLeapYear(year){
if((year%4==0&&y
ear%100!=0)||year%400==0)
return true;
else
return false;
}
//有效证件判断
function isValidate(idNumStr){
if(idNumStr.length<18){
return false ;
}
var ValCodeArr = [ "1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2" ];
var ValCodeArrUp = [ "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" ];催眠的轻音乐
比较污的看了会湿的污文段var Wi = [ "7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7",
"9", "10", "5", "8", "4", "2" ];
// ================ 判断最后一位的值 ================
//alert("==="+ idNumStr.charAt(0)+"---"+Wi[0] );
九月九日重阳节的来历和意义var TotalmulAiWi = 0;
for (var i = 0; i < 17; i++) {
TotalmulAiWi = TotalmulAiWi + (idNumStr.charAt(i) * Wi[i]);
}
var modValue = TotalmulAiWi % 11;
if( ValCodeArr[modValue]==(idNumStr.charAt(17)) || ValCodeArrUp[modValue]==(idNumStr.charAt(17)) ) {
//alert("===true" );
return true ;
}else {
//alert("===false" );
return false ;
}
}
function save(IDnumber) {
if (window.localStorage) { // Only do this if the browser supports it
localStorage.loan_IDnumber = IDnumber;
}
}
黄晓明婚礼嘉宾// Automatically attempt to restore input fields when the document first loads.
几号冬至?
// If the browser supports localStorage and we have some stored data
if (window.localStorage && localStorage.loan_IDnumber) {
}
};
</script>
</body>
</html>
发布评论