javascript 表单规则集合对象

时间:2009-07-21    点击:162   
复制代码 代码如下:

<script type="text/javascript">
//更多的验证可以继续添加到errMsg对象里
var errMsg={
required:{
msg:"This field is required.",
//load参数指定是否在加载的时候验证
test:function(obj,load){
return obj.value.length > 0 || load || obj.value==obj.defaultValue;
}
},
//验证邮件
email:{
meg:"Not a valid email address.",
test:function(obj){
return /^[a-z0-9A-Z+_.-]+\@([a-z0-9A-Z-_]+\.)+[a-z0-9]{2,4}$/i.test(obj.value);
}
},
//验证网址
url:{
msg:"Not a valid URL.",
test:function(obj){
return obj.value=="http://" || /^https?:\/\/([a-z0-9-]+\.)+[a-z0-9]{2,4}.*$/.test(obj.value);
}
}
}
//Example
onload=function(){
$("url").onblur=function(){
if(errMsg.url.test(this)){
alert("right");
}else{
alert(errMsg.url.msg);
}
}
}
</script>
JavaScript 继承的实现
jquery text,radio,checkbox,select操作实现代码
javascript 字符 Escape,encodeURI,encodeURIComponent
jQuery 1.3 和 Validation 验证插件1.5.1
javascript xml为数据源的下拉框控件
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved