var sfz_qian="5107221989";
2 var sfz_hou4="8625";
3 var sfzhm="";
4 for(i=1;i<=12;i++)
5 {
6 //为了程序的方便,我就假设每个月有31天
7 for(j=1;j<=31;j++){
8 if(i<10){
9 if(j<10){
10 sfzhm=sfz_qian+"0"+i+"0"+j+sfz_hou4;
11 }else{
12 sfzhm=sfz_qian+"0"+i+j+sfz_hou4;
13 }
14 result=getvalidcode(sfzhm);
15 if(result!=false){
16 console.log(result);
17 }
18
19 }else{
20 if(j<10){
21 sfzhm=sfz_qian+i+"0"+j+sfz_hou4;
22 }else{
23 sfzhm=sfz_qian+i+j+sfz_hou4;
24 }
25 result=getvalidcode(sfzhm);
26 if(result!=false){
27 console.log(result);
28 }
29
30 }
31
32 }
33 }
34
35
36
37 function getvalidcode(sfzhm_new){
38
39 var sum=0;
40 var weight=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2];
41 var validate=['1','0','X','9','8','7','6','5','4','3','2'];
42 for(m=0;m<sfzhm_new.length-1;m++){
43 sum+=sfzhm_new[m]*weight[m];
44 }
45 mode=sum%11;
46 if(sfzhm_new[17]==validate[mode]){
47 return sfzhm_new;
48 }else{
49 return false;
50 }
51
52 }
console