身份证严格验证等

1.身份证严格验证:

 1<script>   
 2var aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}   
 3  
 4function cidInfo(sId){   
 5var iSum=0   
 6var info=""   
 7if(!/^\d{17}(\d|x)$/i.test(sId))return false;   
 8sId=sId.replace(/x$/i,"a");   
 9if(aCity[parseInt(sId.substr(0,2))]==null)return "Error:非法地区";   
10sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));   
11var d=new Date(sBirthday.replace(/-/g,"/"))   
12if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return "Error:非法生日";   
13for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)   
14if(iSum%11!=1)return "Error:非法证号";   
15return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女")   
16} 
17
18document.write(cidInfo("380524198002300016"),"
19");   
20document.write(cidInfo("340524198002300019"),"
21")   
22document.write(cidInfo("340524197711111111"),"
23")   
24document.write(cidInfo("34052419800101001x"),"
25");   
26</script>

2.验证IP地址

 1<script language="JavaScript">   
 2function isip(s){   
 3var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};   
 4var re=s.split(".")   
 5return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false   
 6} 
 7
 8var s="202.197.78.129";   
 9alert(isip(s))   
10</script>

3.加sp1后还能用的无边框窗口!!

 1<html xmlns:ie="">
 2<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 3<ie:download id="include" style="behavior:url(#default#download)"></ie:download>
 4<title>Chromeless Window</title>
 5<script language="JScript">   
 6/*--- Special Thanks For andot ---*/ 
 7
 8/*   
 9This following code are designed and writen by Windy_sk < [email protected] >   
10You can use it freely, but u must held all the copyright items!   
11*/ 
12
13/*--- Thanks For andot Again ---*/ 
14
15var CW_width= 400;   
16var CW_height= 300;   
17var CW_top= 100;   
18var CW_left= 100;   
19var CW_url= "/";   
20var New_CW= window.createPopup();   
21var CW_Body= New_CW.document.body;   
22var content= "";   
23var CSStext= "margin:1px;color:black; border:2px outset;border-style:expression(onmouseout=onmouseup=function(){this.style.borderStyle='outset'}, onmousedown=function(){if(event.button!=2)this.style.borderStyle='inset'});background-color:buttonface;width:16px;height:14px;font-size:12px;line-height:11px;cursor:Default;"; 
24
25//Build Window   
26include.startDownload(CW_url, function(source){content=source}); 
27
28function insert_content(){   
29var temp = "";   
30CW_Body.style.overflow= "hidden";   
31CW_Body.style.backgroundColor= "white";   
32CW_Body.style.border= "solid black 1px";   
33content = content.replace(/<a ([^>]*)>/g,"<a onclick='parent.open(this.href);return false' $1>");   
34temp += "<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>";   
35temp += "<tr style=';font-size:12px;background:#0099CC;height:20;cursor:default' ondblclick=\"Max.innerText=Max.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\" onmouseup='parent.drag_up(event)' onmousemove='parent.drag_move(event)' onmousedown='parent.drag_down(event)' onselectstart='return false' oncontextmenu='return false'>";   
36temp += "<td style='color:#ffffff;padding-left:5px'>Chromeless Window For IE6 SP1</td>";   
37temp += "<td style='color:#ffffff;padding-right:5px;' align=right>";   
38temp += "<span id=Help onclick=\"alert('Chromeless Window For IE6 SP1 - Ver 1.0\\\n\\\nCode By Windy_sk\\\n\\\nSpecial Thanks For andot')\" style=\""+CSStext+"font-family:System;padding-right:2px;\">?</span>";   
39temp += "<span id=Min onclick='parent.New_CW.hide();parent.blur()' style=\""+CSStext+"font-family:Webdings;\" title='Minimum'>0</span>";   
40temp += "<span id=Max onclick=\"this.innerText=this.innerText=='1'?'2':'1';parent.if_max=!parent.if_max;parent.show_CW();\" style=\""+CSStext+"font-family:Webdings;\" title='Maximum'>1</span>";   
41temp += "<span id=Close onclick='parent.opener=null;parent.close()' style=\""+CSStext+"font-family:System;padding-right:2px;\" title='Close'>x</span>";   
42temp += "</td></tr><tr><td colspan=2>";   
43temp += "<div id=include style='overflow:scroll;overflow-x:hidden;overflow-y:auto; HEIGHT: 100%; width:"+CW_width+"'>";   
44temp += content;   
45temp += "</div>";   
46temp += "</td></tr></table>";   
47CW_Body.innerHTML = temp;   
48} 
49
50setTimeout("insert_content()",1000); 
51
52var if_max = true;   
53function show_CW(){   
54window.moveTo(10000, 10000);   
55if(if_max){   
56New_CW.show(CW_top, CW_left, CW_width, CW_height);   
57if(typeof(New_CW.document.all.include)!="undefined"){   
58New_CW.document.all.include.style.width = CW_width;   
59New_CW.document.all.Max.innerText = "1";   
60} 
61
62}else{   
63New_CW.show(0, 0, screen.width, screen.height);   
64New_CW.document.all.include.style.width = screen.width;   
65}   
66} 
67
68window.onfocus = show_CW;   
69window.onresize = show_CW; 
70
71// Move Window   
72var drag_x,drag_y,draging=false 
73
74function drag_move(e){   
75if (draging){   
76New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);   
77return false;   
78}   
79} 
80
81function drag_down(e){   
82if(e.button==2)return;   
83if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;   
84drag_x=e.clientX;   
85drag_y=e.clientY;   
86draging=true;   
87e.srcElement.setCapture();   
88} 
89
90function drag_up(e){   
91draging=false;   
92e.srcElement.releaseCapture();   
93if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;   
94CW_top = e.screenX-drag_x;   
95CW_left = e.screenY-drag_y;   
96} 
97
98</script>
99</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus