经常用到的javaScript技术代码

<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"> </script>
一、验证类 http://www.pconcool.com
1、数字验证内 http://www.pconcool.com
1.1 整数 http://www.pconcool.com
1.2 大于0的整数 (用于传来的ID的验证) http://www.pconcool.com
1.3 负整数的验证 http://www.pconcool.com
1.4 整数不能大于iMax http://www.pconcool.com
1.5 整数不能小于iMin http://www.pconcool.com
2、时间类 http://www.pconcool.com
2.1 短时间,形如 (13:04:06) http://www.pconcool.com
2.2 短日期,形如 (2003-12-05) http://www.pconcool.com
2.3 长时间,形如 (2003-12-05 13:04:06) http://www.pconcool.com
2.4 只有年和月。形如(2003-05,或者2003-5) http://www.pconcool.com
2.5 只有小时和分钟,形如(12:03) http://www.pconcool.com
3、表单类 http://www.pconcool.com
3.1 所有的表单的值都不能为空 http://www.pconcool.com
3.2 多行文本框的值不能为空。 http://www.pconcool.com
3.3 多行文本框的值不能超过sMaxStrleng http://www.pconcool.com
3.4 多行文本框的值不能少于sMixStrleng http://www.pconcool.com
3.5 判断单选框是否选择。 http://www.pconcool.com
3.6 判断复选框是否选择. http://www.pconcool.com
3.7 复选框的全选,多选,全不选,反选 http://www.pconcool.com
3.8 文件上传过程中判断文件类型 http://www.pconcool.com
4、字符类 http://www.pconcool.com
4.1 判断字符全部由a-Z或者是A-Z的字字母组成 http://www.pconcool.com
4.2 判断字符由字母和数字组成。 http://www.pconcool.com
4.3 判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母 http://www.pconcool.com
4.4 字符串替换函数.Replace(); http://www.pconcool.com
5、浏览器类 http://www.pconcool.com
5.1 判断浏览器的类型 http://www.pconcool.com
5.2 判断ie的版本 http://www.pconcool.com
5.3 判断客户端的分辨率 http://www.pconcool.com

6、结合类http://www.pconcool.com
6.1 email的判断。http://www.pconcool.com
6.2 手机号码的验证http://www.pconcool.com
6.3 身份证的验证

http://www.pconcool.com
二、功能类

1、时间与相关控件类http://www.pconcool.com
1.1 日历http://www.pconcool.com
1.2 时间控件http://www.pconcool.com
1.3 万年历http://www.pconcool.com
1.4 显示动态显示时钟效果(文本,如OA中时间)http://www.pconcool.com
1.5 显示动态显示时钟效果 (图像,像手表) http://www.pconcool.com
2、表单类http://www.pconcool.com
2.1 自动生成表单http://www.pconcool.com
2.2 动态添加,修改,删除下拉框中的元素http://www.pconcool.com
2.3 可以输入内容的下拉框http://www.pconcool.com
2.4 多行文本框中只能输入iMax文字。如果多输入了,自动减少到iMax个文字(多用于短信发送)

3、打印类http://www.pconcool.com
3.1 打印控件http://www.pconcool.com
4、事件类http://www.pconcool.com
4.1 屏蔽右键http://www.pconcool.com
4.2 屏蔽所有功能键http://www.pconcool.com
4.3 --> 和<-- F5 F11,F9,F1http://www.pconcool.com
4.4 屏蔽组合键ctrl+Nhttp://www.pconcool.com
5、网页设计类http://www.pconcool.com
5.1 连续滚动的文字,图片(注意是连续的,两段文字和图片中没有空白出现)http://www.pconcool.com
5.2 html编辑控件类http://www.pconcool.com
5.3 颜色选取框控件http://www.pconcool.com
5.4 下拉菜单http://www.pconcool.com
5.5 两层或多层次的下拉菜单http://www.pconcool.com
5.6 仿IE菜单的按钮。(效果如rongshuxa.com的导航栏目)http://www.pconcool.com
5.7 状态栏,title栏的动态效果(例子很多,可以研究一下)http://www.pconcool.com
5.8 双击后,网页自动滚屏http://www.pconcool.com
6、树型结构。http://www.pconcool.com
6.1 asp+SQL版http://www.pconcool.com
6.2 asp+xml+sql版http://www.pconcool.com
6.3 java+sql或者java+sql+xmlhttp://www.pconcool.com
7、无边框效果的制作http://www.pconcool.com
8、连动下拉框技术http://www.pconcool.com
9、文本排序http://www.pconcool.com
---------------------------------------------------------------------------------------

一、验证类http://www.pconcool.com
1、数字验证内http://www.pconcool.com
1.1 整数http://www.pconcool.com
/^(-|/+)?/d+$/.test(str)http://www.pconcool.com
1.2 大于0的整数 (用于传来的ID的验证)http://www.pconcool.com
/^/d+$/.test(str)http://www.pconcool.com
1.3 负整数的验证http://www.pconcool.com
/^-/d+$/.test(str)http://www.pconcool.com
2、时间类http://www.pconcool.com
2.1 短时间,形如 (13:04:06)http://www.pconcool.com
function isTime(str)http://www.pconcool.com
{http://www.pconcool.com
var a = str.match(/^(/d{1,2})(?(/d{1,2})/2(/d{1,2})$/);http://www.pconcool.com
if (a == null) {alert('输入的参数不是时间格式'); return false;}http://www.pconcool.com
if (a[1]>24 || a[3]>60 || a[4]>60)http://www.pconcool.com
{http://www.pconcool.com
alert("时间格式不对");http://www.pconcool.com
return falsehttp://www.pconcool.com
}http://www.pconcool.com
return true;http://www.pconcool.com
}http://www.pconcool.com
2.2 短日期,形如 (2003-12-05)http://www.pconcool.com
function strDateTime(str)http://www.pconcool.com
{http://www.pconcool.com
var r = str.match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/); http://www.pconcool.com
if(r==null)return false; http://www.pconcool.com
var d= new Date(r[1], r[3]-1, r[4]); http://www.pconcool.com
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);http://www.pconcool.com
}http://www.pconcool.com
2.3 长时间,形如 (2003-12-05 13:04:06)http://www.pconcool.com
function strDateTime(str)http://www.pconcool.com
{http://www.pconcool.com
var reg = /^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2}) (/d{1,2})/d{1,2})/d{1,2})$/; http://www.pconcool.com
var r = str.match(reg); http://www.pconcool.com
if(r==null)return false; http://www.pconcool.com
var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); http://www.pconcool.com
return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);http://www.pconcool.com
}http://www.pconcool.com
2.4 只有年和月。形如(2003-05,或者2003-5)http://www.pconcool.com
2.5 只有小时和分钟,形如(12:03)http://www.pconcool.com
3、表单类http://www.pconcool.com
3.1 所有的表单的值都不能为空

3.2 多行文本框的值不能为空。http://www.pconcool.com
3.3 多行文本框的值不能超过sMaxStrlenghttp://www.pconcool.com
3.4 多行文本框的值不能少于sMixStrlenghttp://www.pconcool.com
3.5 判断单选框是否选择。http://www.pconcool.com
3.6 判断复选框是否选择.http://www.pconcool.com
3.7 复选框的全选,多选,全不选,反选http://www.pconcool.com
3.8 文件上传过程中判断文件类型http://www.pconcool.com
4、字符类http://www.pconcool.com
4.1 判断字符全部由a-Z或者是A-Z的字字母组成

4.2 判断字符由字母和数字组成。

4.3 判断字符由字母和数字,下划线,点号组成.且开头的只能是下划线和字母http://www.pconcool.com
/^([a-zA-z_]{1})([/w]*)$/g.test(str)http://www.pconcool.com
4.4 字符串替换函数.Replace();http://www.pconcool.com
5、浏览器类http://www.pconcool.com
5.1 判断浏览器的类型http://www.pconcool.com
window.navigator.appNamehttp://www.pconcool.com
5.2 判断ie的版本http://www.pconcool.com
window.navigator.appVersionhttp://www.pconcool.com
5.3 判断客户端的分辨率http://www.pconcool.com
window.screen.height; window.screen.width;

6、结合类http://www.pconcool.com
6.1 email的判断。http://www.pconcool.com
function ismail(mail)http://www.pconcool.com
{http://www.pconcool.com
return(new RegExp(/^/w+((-/w+)|(/./w+))*/-AT-[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/).test(mail));http://www.pconcool.com
}http://www.pconcool.com
6.2 手机号码的验证http://www.pconcool.com
6.3 身份证的验证http://www.pconcool.com
function isIdCardNo(num)http://www.pconcool.com
{http://www.pconcool.com
if (isNaN(num)) {alert("输入的不是数字!"); return false;}http://www.pconcool.com
var len = num.length, re; http://www.pconcool.com
if (len == 15)http://www.pconcool.com
re = new RegExp(/^(/d{6})()?(/d{2})(/d{2})(/d{2})(/d{3})$/);http://www.pconcool.com
else if (len == 18)http://www.pconcool.com
re = new RegExp(/^(/d{6})()?(/d{4})(/d{2})(/d{2})(/d{3})(/d)$/);http://www.pconcool.com
else {alert("输入的数字位数不对!"); return false;}http://www.pconcool.com
var a = num.match(re);http://www.pconcool.com
if (a != null)http://www.pconcool.com
{http://www.pconcool.com
if (len==15)http://www.pconcool.com
{http://www.pconcool.com
var D = new Date("19"+a[3]+"/"+a[4]+"/"+a[5]);http://www.pconcool.com
var B = D.getYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];http://www.pconcool.com
}http://www.pconcool.com
elsehttp://www.pconcool.com
{http://www.pconcool.com
var D = new Date(a[3]+"/"+a[4]+"/"+a[5]);http://www.pconcool.com
var B = D.getFullYear()==a[3]&&(D.getMonth()+1)==a[4]&&D.getDate()==a[5];http://www.pconcool.com
}http://www.pconcool.com
if (!B) {alert("输入的身份证号 "+ a[0] +" 里出生日期不对!"); return false;}http://www.pconcool.com
}http://www.pconcool.com
return true;http://www.pconcool.com
}http://www.pconcool.com
-------------------------------------------------------------------------------------

3.7 复选框的全选,多选,全不选,反选

全选

 

 

 

 

 

 

http://www.pconcool.com
全选

 

 

 

 

 

 

 

function checkAll(str)http://www.pconcool.com
{http://www.pconcool.com
var a = document.getElementsByName(str);http://www.pconcool.com
var n = a.length;http://www.pconcool.com
for (var i=0; ia[i].checked = window.event.srcElement.checked;http://www.pconcool.com
}http://www.pconcool.com
function checkItem(str)http://www.pconcool.com
{http://www.pconcool.com
var e = window.event.srcElement;http://www.pconcool.com
var all = eval("document.hrong."+ str);http://www.pconcool.com
if (e.checked)http://www.pconcool.com
{http://www.pconcool.com
var a = document.getElementsByName(e.name);http://www.pconcool.com
all.checked = true;http://www.pconcool.com
for (var i=0; i{http://www.pconcool.com
if (!a[i].checked){ all.checked = false; break;}http://www.pconcool.com
}http://www.pconcool.com
}http://www.pconcool.com
else all.checked = false;http://www.pconcool.com
}

http://www.pconcool.com
3.8 文件上传过程中判断文件类型

http://www.pconcool.com
-------------------------------------------------------------------------------------http://www.pconcool.com
1.身份证严格验证:

 

2.验证IP地址

function isip(s){http://www.pconcool.com
var check=function(v){try{return (v<=255 && v>=0)}catch(x){return false}};http://www.pconcool.com
var re=s.split(".")http://www.pconcool.com
return (re.length==4)?(check(re[0]) && check(re[1]) && check(re[2]) && check(re[3])):falsehttp://www.pconcool.com
}

var s="202.197.78.129";http://www.pconcool.com
alert(isip(s))

 

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

 

 

http://www.pconcool.com
/*--- Special Thanks For andot ---*/

/*http://www.pconcool.com
This following code are designed and writen by Windy_sk http://www.pconcool.com
You can use it freely, but u must held all the copyright items!http://www.pconcool.com
/

/- Thanks For andot Again ---*/

var CW_width = 400;http://www.pconcool.com
var CW_height = 300;http://www.pconcool.com
var CW_top = 100;http://www.pconcool.com
var CW_left = 100;http://www.pconcool.com
var CW_url = "/";http://www.pconcool.com
var New_CW = window.createPopup();http://www.pconcool.com
var CW_Body = New_CW.document.body;http://www.pconcool.com
var content = "";http://www.pconcool.com
var CSStext = "margin:1px;color:black; border:2px outset;border-style:expression(οnmοuseοut=οnmοuseup=function(){this.style.borderStyle='outset'}, οnmοusedοwn=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 Windowhttp://www.pconcool.com
include.startDownload(CW_url, function(source){content=source});

function insert_content(){http://www.pconcool.com
var temp = "";http://www.pconcool.com
CW_Body.style.overflow = "hidden";http://www.pconcool.com
CW_Body.style.backgroundColor = "white";http://www.pconcool.com
CW_Body.style.border = "solid black 1px";http://www.pconcool.com
content = content.replace(/]*)>/g,"");http://www.pconcool.com
temp += "";http://www.pconcool.com
temp += "";http://www.pconcool.com
temp += "Chromeless Window For IE6 SP1";http://www.pconcool.com
temp += "";http://www.pconcool.com
temp += "?";http://www.pconcool.com
temp += "0";http://www.pconcool.com
temp += "1";http://www.pconcool.com
temp += "x";http://www.pconcool.com
temp += "";http://www.pconcool.com
temp += "";http://www.pconcool.com
temp += content;http://www.pconcool.com
temp += "

";http://www.pconcool.com
temp += "";http://www.pconcool.com
CW_Body.innerHTML = temp;http://www.pconcool.com
}

setTimeout("insert_content()",1000);

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

}else{http://www.pconcool.com
New_CW.show(0, 0, screen.width, screen.height);http://www.pconcool.com
New_CW.document.all.include.style.width = screen.width;http://www.pconcool.com
}http://www.pconcool.com
}

window.onfocus = show_CW;http://www.pconcool.com
window.onresize = show_CW;

// Move Windowhttp://www.pconcool.com
var drag_x,drag_y,draging=false

function drag_move(e){http://www.pconcool.com
if (draging){http://www.pconcool.com
New_CW.show(e.screenX-drag_x, e.screenY-drag_y, CW_width, CW_height);http://www.pconcool.com
return false;http://www.pconcool.com
}http://www.pconcool.com
}

function drag_down(e){http://www.pconcool.com
if(e.button==2)return;http://www.pconcool.com
if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height)return;http://www.pconcool.com
drag_x=e.clientX;http://www.pconcool.com
drag_y=e.clientY;http://www.pconcool.com
draging=true;http://www.pconcool.com
e.srcElement.setCapture();http://www.pconcool.com
}

function drag_up(e){http://www.pconcool.com
draging=false;http://www.pconcool.com
e.srcElement.releaseCapture();http://www.pconcool.com
if(New_CW.document.body.offsetWidth==screen.width && New_CW.document.body.offsetHeight==screen.height) return;http://www.pconcool.com
CW_top = e.screenX-drag_x;http://www.pconcool.com
CW_left = e.screenY-drag_y;http://www.pconcool.com
}

http://www.pconcool.com
 http://www.pconcool.com
电话号码的验证

要求:http://www.pconcool.com
  (1)电话号码由数字、"("、")"和"-"构成http://www.pconcool.com
  (2)电话号码为3到8位http://www.pconcool.com
  (3)如果电话号码中包含有区号,那么区号为三位或四位http://www.pconcool.com
  (4)区号用"("、")"或"-"和其他部分隔开http://www.pconcool.com
  (5)移动电话号码为11或12位,如果为12位,那么第一位为0http://www.pconcool.com
  (6)11位移动电话号码的第一位和第二位为"13"http://www.pconcool.com
  (7)12位移动电话号码的第二位和第三位为"13"http://www.pconcool.com
  根据这几条规则,可以与出以下正则表达式:http://www.pconcool.com
  (^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)

 

function PhoneCheck(s) {http://www.pconcool.com
var str=s;http://www.pconcool.com
var reg=/(^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/http://www.pconcool.com
alert(reg.test(str));http://www.pconcool.com
}

 

--------------------------------------------------------------------------------------

http://www.pconcool.com
---------------------------------------------------------------------------------

//检验法人代码http://www.pconcool.com
function isCorporationCode(s){http://www.pconcool.com
var patrn=/^(/d){15}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验登录名:只能输入5-20个以字母开头、可带数字、“_”、“.”的字串http://www.pconcool.com
function isRegisterUserName(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9._]){4,19}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}http://www.pconcool.com
//校验用户姓名:只能输入1-30个以字母开头的字串http://www.pconcool.com
function isTrueName(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[^`~!@#$%^&*()+-=|///[/]/{/}:;/'/,.<>/? 0-9]{2,19}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验密码:只能输入6-15个字母、数字http://www.pconcool.com
function isPasswd(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[a-zA-Z0-9]{6,15}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//检验体重http://www.pconcool.com
function isAvoirdupois(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[1-9]{1}[0-9]{0,2}$/;http://www.pconcool.com
var patrn2=/^[1-9]{1}$/;http://www.pconcool.com
var intPart=s.indexOf('.');http://www.pconcool.com
var decPart=s.lastIndexOf('.');http://www.pconcool.com
if (intPart==-1 && patrn.exec(s) && eval(s)>=2 && eval(s)<=200) return truehttp://www.pconcool.com
if (intPart!=decPart || intPart==0 || intPart+2!=s.length) return falsehttp://www.pconcool.com
if (!patrn.exec(s.substring(0,intPart)) || !patrn2.exec(s.substring(decPart+1))) return falsehttp://www.pconcool.com
if (eval(s)<2 || eval(s)>200) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验普通电话、传真号码:可以“+”开头,除数字外,可含有“-”http://www.pconcool.com
function isTel(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[+]{0,1}(/d){1,3}[ ]?([-]?((/d)|[ ]){1,12})+$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验手机号码:必须以数字开头,除数字外,可含有“-”http://www.pconcool.com
function isMobile(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[+]{0,1}(/d){1,3}[ ]?([-]?((/d)|[ ]){1,12})+$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验地区代码http://www.pconcool.com
function isAreaCode(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^(/d){6}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验邮政编码http://www.pconcool.com
function isPostalCode(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[1-9]{1}(/d){5}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验搜索关键字http://www.pconcool.com
function isSearch(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[^`~!@#$%^&*()+=|///[/]/{/}:;/'/,.<>/? ]{1}[^`~!@$%^&()+=|///[/]/{/}:;/'/,.<>?]{0,19}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验是否为ip地址http://www.pconcool.com
function isIP(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[0-9.]{1,20}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//检验页码是否正确http://www.pconcool.com
function isPage(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[1-9]{1}[0-9]{0,2}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//表单输入值错误提示http://www.pconcool.com
function vErr(o,s){http://www.pconcool.com
alert(s);http://www.pconcool.com
if (o) o.focus();http://www.pconcool.com
return false;http://www.pconcool.com
}

//判断单选http://www.pconcool.com
function chkRadio(o){http://www.pconcool.com
for (i=0;iif (o[i].checked) return true;http://www.pconcool.com
}http://www.pconcool.com
return false;http://www.pconcool.com
} http://www.pconcool.com
//====================================表单类================================http://www.pconcool.com
// 文件上传过程中判断文件类型http://www.pconcool.com
/*

/

//表单的值不能为空http://www.pconcool.com
function isNull(elem){http://www.pconcool.com
//var pattern=/^/s+|/s+$/;http://www.pconcool.com
if(elem.replace(/(^/s+|/s$)/g, "")==""){http://www.pconcool.com
return false;http://www.pconcool.com
}else{http://www.pconcool.com
return true;http://www.pconcool.com
}http://www.pconcool.com
}http://www.pconcool.com
//不能超过imax字符http://www.pconcool.com
function imax(elem){http://www.pconcool.com
if(elem.length>imax){http://www.pconcool.com
return false;http://www.pconcool.com
}else{http://www.pconcool.com
return true;http://www.pconcool.com
}http://www.pconcool.com
}http://www.pconcool.com
//不能少于imix字符http://www.pconcool.com
function imix(elem){http://www.pconcool.com
if(elem.lengthreturn false;http://www.pconcool.com
}else{http://www.pconcool.com
return true;http://www.pconcool.com
}http://www.pconcool.com
}http://www.pconcool.com
//输入为中文判断http://www.pconcool.com
function isChinese(elem){http://www.pconcool.com
var pattern=/[^/x00-/xff]/g;http://www.pconcool.com
if(pattern.test(elem)){http://www.pconcool.com
//包含中文http://www.pconcool.com
return false;http://www.pconcool.com
}else{http://www.pconcool.com
//不包含中文http://www.pconcool.com
return true;http://www.pconcool.com
}http://www.pconcool.com
}

/ *********************************************************************************************************************

 

 

 

.cMenu {http://www.pconcool.com
FILTER: alpha(opacity=0);BACKGROUND-COLOR: #D6D3CE;BORDER-BOTTOM: #666666 2px solid; BORDER-LEFT: #E4E4E4 2px solid; BORDER-RIGHT: #666666 2px solid; BORDER-TOP: #E4E4E4 2px solid; COLOR: #000000; CURSOR: default; FONT-SIZE: 9pt; color:#000000;FONT-WEIGHT: normal; LINE-HEIGHT: 20px; POSITION: absolute; VISIBILITY: hidden; WIDTH: 110pxhttp://www.pconcool.com
}http://www.pconcool.com
.menuitems {http://www.pconcool.com
font-size:9pt;http://www.pconcool.com
MARGIN: 2px;http://www.pconcool.com
PADDING-BOTTOM: 0px;http://www.pconcool.com
PADDING-LEFT: 15px;http://www.pconcool.com
PADDING-RIGHT: 3px;http://www.pconcool.com
PADDING-TOP: 0px;http://www.pconcool.com
}

 

 

 

<!--[if IE]>http://www.pconcool.com
οnmοuseοver=highlightie5()>

电话号码的验证

要求:http://www.pconcool.com
  (1)电话号码由数字、"("、")"和"-"构成http://www.pconcool.com
  (2)电话号码为3到8位http://www.pconcool.com
  (3)如果电话号码中包含有区号,那么区号为三位或四位http://www.pconcool.com
  (4)区号用"("、")"或"-"和其他部分隔开http://www.pconcool.com
  (5)移动电话号码为11或12位,如果为12位,那么第一位为0http://www.pconcool.com
  (6)11位移动电话号码的第一位和第二位为"13"http://www.pconcool.com
  (7)12位移动电话号码的第二位和第三位为"13"http://www.pconcool.com
  根据这几条规则,可以与出以下正则表达式:http://www.pconcool.com
  (^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)

http://www.pconcool.com
<script language="javascript">http://www.pconcool.com
function PhoneCheck(s) {http://www.pconcool.com
var str=s;http://www.pconcool.com
var reg=/(^[0-9]{3,4}/-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^/([0-9]{3,4}/)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)/http://www.pconcool.com
alert(reg.test(str));http://www.pconcool.com
}http://www.pconcool.com
</script>http://www.pconcool.com
<input type=text name="iphone">http://www.pconcool.com
<input type=button οnclick="PhoneCheck(document.all.iphone.value)" value="Check">http://www.pconcool.com
----------------------------------------------------------------------------------------

<%http://www.pconcool.com
'********************************************http://www.pconcool.com
'函数功能:正则表达式校验http://www.pconcool.com
'参数patrn:要校验的类型http://www.pconcool.com
' "User" - 用户名http://www.pconcool.com
' "Truename" - 英文姓名http://www.pconcool.com
' "Passwd" - 密码http://www.pconcool.com
' "Tel" - 电话/传真http://www.pconcool.com
' "Mobil" - 手机http://www.pconcool.com
' "Date" - 日期(格式:yyyy-mm-dd)http://www.pconcool.com
' "Email" - 电子邮件http://www.pconcool.com
' "Postalcode" - 邮政编码http://www.pconcool.com
' "Search" - 搜索关键字http://www.pconcool.com
' "Int" - 整数http://www.pconcool.com
'参数strng:要校验的字串http://www.pconcool.com
'返回值:校验结果,正确返回true,错误返回falsehttp://www.pconcool.com
'********************************************http://www.pconcool.com
Function IsVerify(patrn,strng)http://www.pconcool.com
strng=Trim(strng)http://www.pconcool.com
Select Case patrnhttp://www.pconcool.com
Case "User" '用户名http://www.pconcool.com
patrn="^[a-z]{1}([a-z0-9]|[._]){2,19}$"http://www.pconcool.com
Case "Truename" '英文姓名http://www.pconcool.com
patrn="^[a-zA-Z]{1,30}$"http://www.pconcool.com
Case "Passwd" '密码http://www.pconcool.com
patrn="^(/w){6,20}$"http://www.pconcool.com
Case "Tel" '电话/传真http://www.pconcool.com
patrn="^[+]{0,1}(/d){1,3}[ ]?([-]?((/d)|[ ]){1,12})+$"http://www.pconcool.com
Case "Mobil" '手机http://www.pconcool.com
patrn="^(/d)+[-]?(/d){6,12}$"http://www.pconcool.com
Case "Date" '日期(格式:yyyy-mm-dd)http://www.pconcool.com
patrn="^[12]{1}(/d){3}[-][01]?(/d){1}[-][0123]?(/d){1}$"http://www.pconcool.com
Case "Email" '电子邮件http://www.pconcool.com
patrn="^((/w)|[-]|[.])+@(((/w)|[-])+[.])+[a-z]{2,4}$"http://www.pconcool.com
Case "Postalcode" '邮政编码http://www.pconcool.com
patrn="^[a-z0-9 ]{3,12}$"http://www.pconcool.com
Case "Search" '搜索关键字http://www.pconcool.com
patrn="^[^`~!@#$%^&*()+=|///[/]/{/}:;/'/,.<>/?]{1}[^`~!@$%^&()+=|///[/]/{/}:;/'/,.<>?]{0,19}$"http://www.pconcool.com
Case "Int" '整数http://www.pconcool.com
patrn="^[1-9]{1}[0-9]{0,6}$"http://www.pconcool.com
Case "Array"http://www.pconcool.com
patrn="^[0-9]{1}([0-9]|[/,]){0,150}$"http://www.pconcool.com
End Selecthttp://www.pconcool.com
Dim regExhttp://www.pconcool.com
Dim Matchhttp://www.pconcool.com
Set regEx = New RegExphttp://www.pconcool.com
regEx.Pattern = patrnhttp://www.pconcool.com
regEx.IgnoreCase = Truehttp://www.pconcool.com
regEx.Global = Truehttp://www.pconcool.com
Matches = regEx.test(strng)http://www.pconcool.com
IsVerify = Matcheshttp://www.pconcool.com
Set regEx = Nothinghttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:对输入框的特殊字串进行过滤保存http://www.pconcool.com
'参数strPass:过滤前的字符串http://www.pconcool.com
'返回值:过滤后的字符串http://www.pconcool.com
'********************************************http://www.pconcool.com
Function SQLencode(byVal strPass)http://www.pconcool.com
strPass = Replace(strPass, "&", "&")http://www.pconcool.com
strPass = Replace(strPass, "<", "<")http://www.pconcool.com
strPass = Replace(strPass, ">", ">")http://www.pconcool.com
strPass = Replace(strPass, """", """)http://www.pconcool.com
strPass = Replace(strPass, "'", "'")http://www.pconcool.com
strPass = Replace(strPass, " ", " ")http://www.pconcool.com
strPass = Replace(strPass,chr(13)&chr(10),"<br/>")http://www.pconcool.com
SQLencode = strPasshttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:对SQLencode函数过滤后的字符串进行还原http://www.pconcool.com
'参数strPass:经过过滤后的字符串http://www.pconcool.com
'返回值:还原的过滤前的字符串http://www.pconcool.com
'********************************************http://www.pconcool.com
Function SQLdecode(byVal strPass)http://www.pconcool.com
If Not isNull(strPass) Thenhttp://www.pconcool.com
strPass = Replace(strPass, "<", "<")http://www.pconcool.com
strPass = Replace(strPass, ">", ">")http://www.pconcool.com
strPass = Replace(strPass, ""","""" )http://www.pconcool.com
strPass = Replace(strPass, "'","'" )http://www.pconcool.com
strPass = Replace(strPass,"<br/>",chr(13)&chr(10))http://www.pconcool.com
End Ifhttp://www.pconcool.com
SQLdecode = strPasshttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:生成随机密码(字符为数字与大小写字母集合)http://www.pconcool.com
'参数length:密码长度http://www.pconcool.com
'返回值:随机密码http://www.pconcool.com
'********************************************http://www.pconcool.com
Function random(length)http://www.pconcool.com
Dim n,strhttp://www.pconcool.com
rnds=""http://www.pconcool.com
Randomizehttp://www.pconcool.com
For i=1 To lengthhttp://www.pconcool.com
n=Int(75*Rnd+48)http://www.pconcool.com
If (n>57 and n<65) or (n>90 and n<97) Thenhttp://www.pconcool.com
i=i-1http://www.pconcool.com
Elsehttp://www.pconcool.com
rnds=rnds&Chr(n)http://www.pconcool.com
End Ifhttp://www.pconcool.com
Nexthttp://www.pconcool.com
random=rndshttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:对密码进行加密/解密(最大长度为15位)http://www.pconcool.com
'********************************************http://www.pconcool.com
Function Encrypt(preString)http://www.pconcool.com
Dim pwds,shttp://www.pconcool.com
pwds=""http://www.pconcool.com
s=Left(preString,15)http://www.pconcool.com
For i=1 To Len(s)http://www.pconcool.com
seed=170-Asc(Mid(s,i,1))-ihttp://www.pconcool.com
pwds=pwds & Chr(seed)http://www.pconcool.com
Nexthttp://www.pconcool.com
Encrypt=pwdshttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:格式化当前时间字串http://www.pconcool.com
'参数:无http://www.pconcool.com
'返回值:返回当前时间的纯数字字符串方式的表示(例如:当前时间2001-10-3 2:34:6,返回字符串"20011003023406")http://www.pconcool.com
'********************************************http://www.pconcool.com
Function TheDate()http://www.pconcool.com
y=year(date())http://www.pconcool.com
m=month(date())http://www.pconcool.com
d=day(date())http://www.pconcool.com
h=Hour(time())http://www.pconcool.com
n=Minute(time())http://www.pconcool.com
s=Second(time())http://www.pconcool.com
If Len(m)=1 Then m="0"&mhttp://www.pconcool.com
If Len(d)=1 Then d="0"&dhttp://www.pconcool.com
If Len(h)=1 Then h="0"&hhttp://www.pconcool.com
If Len(n)=1 Then n="0"&nhttp://www.pconcool.com
If Len(s)=1 Then s="0"&shttp://www.pconcool.com
thedate=y&m&d&h&n&shttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:返回字符串的长度http://www.pconcool.com
'参数:字符串http://www.pconcool.com
'返回值:字符串长度http://www.pconcool.com
'********************************************http://www.pconcool.com
Function strLen(str)http://www.pconcool.com
dim p_lenhttp://www.pconcool.com
p_len=0http://www.pconcool.com
strlen=0http://www.pconcool.com
if trim(str)<>"" thenhttp://www.pconcool.com
p_len=len(trim(str))http://www.pconcool.com
for xx=1 to p_lenhttp://www.pconcool.com
if asc(mid(str,xx,1))<0 thenhttp://www.pconcool.com
strlen=int(strlen) + 2http://www.pconcool.com
elsehttp://www.pconcool.com
strlen=int(strlen) + 1http://www.pconcool.com
end ifhttp://www.pconcool.com
nexthttp://www.pconcool.com
end ifhttp://www.pconcool.com
End Function

'********************************************http://www.pconcool.com
'函数功能:发送邮件通知http://www.pconcool.com
'参数:字符串http://www.pconcool.com
'返回值:成功/失败http://www.pconcool.com
'********************************************http://www.pconcool.com
Function SendMail(ToAddress, Subject, Body)http://www.pconcool.com
On Error Resume Nexthttp://www.pconcool.com
Set objMail = Server.CreateObject("JMail.Message")http://www.pconcool.com
objMail.From = ADR_Emailhttp://www.pconcool.com
objMail.FromName = "ADR管理中心"http://www.pconcool.com
objMail.Subject = Subjecthttp://www.pconcool.com
objMail.AddRecipient ToAddresshttp://www.pconcool.com
objMail.Body = Bodyhttp://www.pconcool.com
If objMail.Send("") Thenhttp://www.pconcool.com
SendMail = Truehttp://www.pconcool.com
Elsehttp://www.pconcool.com
SendMail = Falsehttp://www.pconcool.com
End Ifhttp://www.pconcool.com
If Err.Number<> 0 Then SendMail = Falsehttp://www.pconcool.com
Set objMail = Nothinghttp://www.pconcool.com
On Error Goto 0http://www.pconcool.com
End Functionhttp://www.pconcool.com
%>http://www.pconcool.com
-----------------------------------------------------------------------------------

//检验法人代码http://www.pconcool.com
function isCorporationCode(s){http://www.pconcool.com
var patrn=/^(/d){15}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验登录名:只能输入5-20个以字母开头、可带数字、“_”、“.”的字串http://www.pconcool.com
function isRegisterUserName(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9._]){4,19}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}http://www.pconcool.com
//校验用户姓名:只能输入1-30个以字母开头的字串http://www.pconcool.com
function isTrueName(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[^`~!@#$%^&*()+-=|///[/]/{/}:;/'/,.<>/? 0-9]{2,19}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验密码:只能输入6-15个字母、数字http://www.pconcool.com
function isPasswd(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[a-zA-Z0-9]{6,15}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//检验体重http://www.pconcool.com
function isAvoirdupois(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[1-9]{1}[0-9]{0,2}$/;http://www.pconcool.com
var patrn2=/^[1-9]{1}$/;http://www.pconcool.com
var intPart=s.indexOf('.');http://www.pconcool.com
var decPart=s.lastIndexOf('.');http://www.pconcool.com
if (intPart==-1 && patrn.exec(s) && eval(s)>=2 && eval(s)<=200) return truehttp://www.pconcool.com
if (intPart!=decPart || intPart==0 || intPart+2!=s.length) return falsehttp://www.pconcool.com
if (!patrn.exec(s.substring(0,intPart)) || !patrn2.exec(s.substring(decPart+1))) return falsehttp://www.pconcool.com
if (eval(s)<2 || eval(s)>200) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验普通电话、传真号码:可以“+”开头,除数字外,可含有“-”http://www.pconcool.com
function isTel(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[+]{0,1}(/d){1,3}[ ]?([-]?((/d)|[ ]){1,12})+$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验手机号码:必须以数字开头,除数字外,可含有“-”http://www.pconcool.com
function isMobile(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[+]{0,1}(/d){1,3}[ ]?([-]?((/d)|[ ]){1,12})+$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验地区代码http://www.pconcool.com
function isAreaCode(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^(/d){6}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验邮政编码http://www.pconcool.com
function isPostalCode(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[1-9]{1}(/d){5}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验搜索关键字http://www.pconcool.com
function isSearch(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[^`~!@#$%^&*()+=|///[/]/{/}:;/'/,.<>/? ]{1}[^`~!@$%^&()+=|///[/]/{/}:;/'/,.<>?]{0,19}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//校验是否为ip地址http://www.pconcool.com
function isIP(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[0-9.]{1,20}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//检验页码是否正确http://www.pconcool.com
function isPage(s)http://www.pconcool.com
{http://www.pconcool.com
var patrn=/^[1-9]{1}[0-9]{0,2}$/;http://www.pconcool.com
if (!patrn.exec(s)) return falsehttp://www.pconcool.com
return truehttp://www.pconcool.com
}

//表单输入值错误提示http://www.pconcool.com
function vErr(o,s){http://www.pconcool.com
alert(s);http://www.pconcool.com
if (o) o.focus();http://www.pconcool.com
return false;http://www.pconcool.com
}

//判断单选http://www.pconcool.com
function chkRadio(o){http://www.pconcool.com
for (i=0;i<o.length;i++){http://www.pconcool.com
if (o[i].checked) return true;http://www.pconcool.com
}http://www.pconcool.com
return false;http://www.pconcool.com
}

 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值