`
xyzroundo
  • 浏览: 500839 次
  • 性别: Icon_minigender_1
  • 来自: 惠州
社区版块
存档分类
最新评论

常用js大全二

    博客分类:
  • js
UP 
阅读更多
1.身份证严格验证:



<script>
var 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:"国外"}

function cidInfo(sId){
var iSum=0
var info=""
if(!/^\d{17}(\dx)$/i.test(sId))return false;
sId=sId.replace(/x$/i,"a");

if(aCity[parseInt(sId.substr(0,2))]==null)return "Error:非法地区";
sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2));
var d=new Date(sBirthday.replace(/-/g,"/"))
if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))return "Error:非法生日";
for(var i = 17;i>=0;i --) iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11)
if(iSum%11!=1)return "Error:非法证号";
return aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女")
}


document.write(cidInfo("380524198002300016"),"<br/>");
document.write(cidInfo("340524198002300019"),"<br/>")
document.write(cidInfo("340524197711111111"),"<br/>")
document.write(cidInfo("34052419800101001x"),"<br/>");
</script>



2.验证IP地址
<SCRIPT LANGUAGE="javascript">
function isip(s){
var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};
var re=s.split(".")
return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):false
}



var s="202.197.78.129";

alert(isip(s))
</SCRIPT>





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

<HTML XMLNS:IE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<IE:Download ID="include" STYLE="behavior:url(#default#download)" />
<title>Chromeless Window</title>



<SCRIPT LANGUAGE="JScript">
/*--- Special Thanks For andot ---*/



/*
This following code are designed and writen by Windy_sk <seasonx@163.net>
You can use it freely, but u must held all the copyright items!
*/



/*--- Thanks For andot Again ---*/



var CW_width= 400;

var CW_height= 300;
var CW_top= 100;
var CW_left= 100;
var CW_url= "/";
var New_CW= window.createPopup();
var CW_Body= New_CW.document.body;
var content= "";
var 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;";


//Build Window

include.startDownload(CW_url, function(source){content=source});



function insert_content(){
var temp = "";
CW_Body.style.overflow= "hidden";
CW_Body.style.backgroundColor= "white";
CW_Body.style.border=  "solid black 1px";
content = content.replace(/<a ([^>]*)>/g,"<a onclick='parent.open(this.href);return false' $1>");
temp += "<table width=100% height=100% cellpadding=0 cellspacing=0 border=0>";
temp += "<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'>";
temp += "<td style='color:#ffffff;padding-left:5px'>Chromeless Window For IE6 SP1</td>";
temp += "<td style='color:#ffffff;padding-right:5px;' align=right>";
temp += "<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>";
temp += "<span id=Min   onclick='parent.New_CW.hide();parent.blur()' style=\""+CSStext+"font-family:Webdings;\" title='Minimum'>0</span>";
temp += "<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>";
temp += "<span id=Close onclick='parent.opener=null;parent.close()' style=\""+CSStext+"font-family:System;padding-right:2px;\" title='Close'>x</span>";
temp += "</td></tr><tr><td colspan=2>";
temp += "<div id=include style='overflow:scroll;overflow-x:hidden;overflow-y:auto; HEIGHT: 100%; width:"+CW_width+"'>";
temp += content;
temp += "</div>";
temp += "</td></tr></table>";
CW_Body.innerHTML = temp;
}


setTimeout("insert_content()",1000);



var if_max = true;

function show_CW(){
window.moveTo(10000, 10000);
if(if_max){
New_CW.show(CW_top, CW_left, CW_width, CW_height);
if(typeof(New_CW.document.all.include)!="undefined"){
New_CW.document.all.include.style.width = CW_width;
New_CW.document.all.Max.innerText = "1";
}


}else{
New_CW.show(0, 0, screen.width, screen.height);
New_CW.document.all.include.style.width = screen.width;
}
}



window.onfocus  = show_CW;
window.onresize = show_CW;



// Move Window
var drag_x,drag_y,draging=false



function drag_move(e){
if (draging){
New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);
return false;
}
}



function drag_down(e){


if(e.button==2)return;
if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;
drag_x=e.clientX;
drag_y=e.clientY;
draging=true;
e.srcElement.setCapture();
}


function drag_up(e){

draging=false;
e.srcElement.releaseCapture();
if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;
CW_top  = e.screenX-drag_x;
CW_left = e.screenY-drag_y;
}



</SCRIPT>
</HTML>





贴两个关于treeview的
  <script language="javascript">
<!--
//初始化选中节点
function initchecknode()
{
var node=TreeView1.getTreeNode("1");
node.setAttribute("Checked","true");
setcheck(node,"true");
FindCheckedFromNode(TreeView1);
}
//oncheck事件
function tree_oncheck(tree)
{
var node=tree.getTreeNode(tree.clickedNodeIndex);
var Pchecked=tree.getTreeNode(tree.clickedNodeIndex).getAttribute("checked");

setcheck(node,Pchecked);
document.all.checked.value="";
document.all.unchecked.value="";
FindCheckedFromNode(TreeView1);
}
//设置子节点选中
function setcheck(node,Pc)
{
var i;
var ChildNode=new Array();
ChildNode=node.getChildren();
 
if(parseInt(ChildNode.length)==0)
  return;
else
{
  for(i=0;i<ChildNode.length;i++)
  {
   var cNode;
   cNode=ChildNode[i];
   if(parseInt(cNode.getChildren().length)!=0)
    setcheck(cNode,Pc);
   cNode.setAttribute("Checked",Pc);
  }
}
}
//获取所有节点状态
function FindCheckedFromNode(node) {
var i = 0;
var nodes = new Array();
nodes = node.getChildren();
 
for (i = 0; i < nodes.length; i++) {
  var cNode;
  cNode=nodes[i];
  if (cNode.getAttribute("Checked"))
   AddChecked(cNode);
  else
      AddUnChecked(cNode);
 
  if (parseInt(cNode.getChildren().length) != 0 ) {

   FindCheckedFromNode(cNode);
  }
}
}
//添加选中节点
function AddChecked(node) {
document.all.checked.value += node.getAttribute("NodeData");
document.all.checked.value += ',';
}
//添加未选中节点
function AddUnChecked(node) {
document.all.unchecked.value += node.getAttribute("NodeData");
document.all.unchecked.value += ',';
}
//-->
  </script>
分享到:
评论

相关推荐

    常用 js 大全常用 js 大全常用 js 大全常用 js 大全常用 js 大全

    2.JS 中的注释为// 3.传统的 HTML 文档顺序是:document-&gt;html-&gt;(head,body) 4.一个浏览器窗口中的 DOM 顺序是: window-&gt;(navigator,screen,history,location,document) 5.得到表单中元素的名称和值:document....

    常用js大全,javascript校验大全

    js大全 . 1.1 全是数字.. 3 1.2 限制 期限 不能大于 100 年.. 4 1.3 将日期格式由yyyy-MM-dd,转换为yyyymmdd,以直接比较两个日 期的大小.. 4 1.4 判断字符串是否全部由数字组成. 5 1.5 判断字符串是否全部由字母...

    常用javascript语句大全

    2.JS中的注释为// 3.传统的HTML文档顺序是:document-&gt;html-&gt;(head,body) 4.一个浏览器窗口中的DOM顺序是:window-&gt;(navigator,screen,history,location,document) 5.得到表单中元素的名称和值:document....

    常用网页广告大全2-js

    常用网页广告大全2-js常用网页广告大全2-js常用网页广告大全2-js

    常用JS总结二

    常用JS总结二

    javascript代码常用大全

    二、功能类 1、时间与相关控件类 1.1 日历 1.2 时间控件 1.3 万年历 1.4 显示动态显示时钟效果(文本,如OA中时间) 1.5 显示动态显示时钟效果 (图像,像手表) 2、表单类 2.1 自动生成表单 2.2 ...

    2020收集——泛微 Ecology流程表单常用JS脚本

    收集统计了泛微OA Ecology流程表单的JS脚本,OA系统管理必备文档。可以参考PDF的文档学习一下,将它转变成自己的知识,后面就可以给泛微做系统维护人员,有事不求人哈……

    javascript 常用代码大全

    二、功能类 1、时间与相关控件类 1.1 日历 1.2 时间控件 1.3 万年历 1.4 显示动态显示时钟效果(文本,如oa中时间) 1.5 显示动态显示时钟效果 (图像,像手表) 2、表单类 2.1 自动生成表单 2.2 ...

    常用网页广告大全1-js

    常用网页广告大全2-js常用网页广告大全2-js

    常用正则表达式集锦 js常用正则验证

    常用js正则表达式 开发必备 只能输入数字:“^[0-9]*$” 只能输入n位的数字:“^\d{n}$” 只能输入至少n位数字:“^\d{n,}$” 只能输入m-n位的数字:“^\d{m,n}$” 只能输入零和非零开头的数字:“^(0|[1-9][0-9]*)...

    两款网页常用js二级下拉导航菜单代码

    两款网页常用js二级下拉导航菜单代码 两款网页常用js二级下拉导航菜单代码 两款网页常用js二级下拉导航菜单代码 两款网页常用js二级下拉导航菜单代码 两款网页常用js二级下拉导航菜单代码

    Three.js实战常用技巧课程

    课程分享——Three.js实战常用技巧,完整版视频课程下载。 课程概述 一、适合有一定的three.js基础学员学习。 二、每节课都有对应的案例源码(有注释) 三、本课程主要针对three.js实际开发中常用的一些技巧进行讲解...

    常用javascript整理

    1.JavaScript的数值处理对象学习 .txt 2.JavaScript的系统函数学习 .txt 3.js中用于对象的语句——with和for...in语句学习专题.txt 4.smallSoftkey小软键盘,大键盘 5.window.open参数详解 .txt 6....

    合并压缩多种常用js2

    合并压缩多种常用js2

    107个常用Javascript语句.doc

    2. Javascript中的注释:使用//符号可以添加注释,注释内容不会被执行。 3. HTML文档结构:传统的HTML文档结构是document-&gt;html-&gt;(head,body),其中head元素中包含文档的元数据,body元素中包含文档的内容。 4. ...

    json2 常用js

    js的开发当中 常常用到的一个js, 可以反序列化json对象等等

    javascript常用代码大全.html

    二、功能类 1、时间与相关控件类 1.1 日历 1.2 时间控件 1.3 万年历 1.4 显示动态显示时钟效果(文本,如OA中时间) 1.5 显示动态显示时钟效果 (图像,像手表) 2、表单类 2.1 自动生成表单 2.2 动态添加,...

    73种网页常用Javascript代码

    "&gt; 2、返回 &lt;form&gt;&lt;input type="button" value="返回上一步" onClick="history.back(-1)"&gt;&lt;/form&gt; 3、查看源码 查看源码" onClick="window.location="view-source:" +window.location.href"&gt; 4、禁止查看源码

    实用JavaScript脚本代码大全

    实用JavaScript脚本代码大全是一些页面中常用控制页面的js,1. oncontextmenu="window.event.returnvalue=false"将彻底屏蔽鼠标右键 (false)&gt;&lt;td&gt;no&lt;/table&gt; 可用于Table 2. ...

    Web设计开发常用Javascript例子

    Web设计开发常用Javascript例子

Global site tag (gtag.js) - Google Analytics