verify.js文件二

function chkLen(field_name, allow_len, label_name,defaultEmpty) {
var s =trim(field_name.value);
if (typeof(defaultEmpty) == "undefined") defaultEmpty = true;
if(isEmpty(s)) {
if (!defaultEmpty) {
field_name.focus();
field_name.style.background=fieldbg;
alert ("Please input " + label_name);
return false;
} else return true;
}
if (getTextLen(s) > allow_len) {
field_name.focus();
field_name.style.background=fieldbg;
alert(label_name + " length not more than " + allow_len + " bytes,Please reInput!");
return false;
}
return true;
}

function chkEmail(field_name,label_name,defaultEmpty) {
var s = field_name.value;
var str = /^[_\-\.0-9a-zA-Z-]+@([0-9a-zA-Z-]+\.)+[a-zA-Z]{2,3}$/;
if (typeof(defaultEmpty) == "undefined") defaultEmpty = true;
if(isEmpty(s)) {
if (!defaultEmpty) {
field_name.focus();
field_name.style.background=fieldbg;
alert ("Please input " + label_name);
return false;
} else return true;
}
if (!str.test(s)) {
field_name.focus();
field_name.style.background=fieldbg;
alert(label_name+" input invalid,Please input right Email.");
return false;
}
return true;
}

function chkMoreEmail(field_name,label_name,defaultEmpty,seperator) {
var s = field_name.value;
var str = /^[_\-\.0-9a-zA-Z-]+@([0-9a-zA-Z-]+\.)+[a-zA-Z]{2,3}$/;
var ss=s.split(seperator);
var mail;
if (typeof(defaultEmpty) == "undefined") defaultEmpty = true;
if(isEmpty(s)) {
if (!defaultEmpty) {
field_name.focus();
field_name.style.background=fieldbg;
alert ("Please input " + label_name);
return false;
} else return true;
}
for( var i=0;i<ss.length;i++){
mail=ss[i];
if (!str.test(mail)) {
field_name.focus();
field_name.style.background=fieldbg;
alert(label_name+" input invalid,Please input right Email.");
return false;
}
}
return true;
}

function chkNum(field_name,label_name,defaultEmpty) {
if (typeof(defaultEmpty) == "undefined") defaultEmpty = true;
var s = field_name.value;
if(isEmpty(s)) {
if (!defaultEmpty) {
field_name.focus();
field_name.style.background=fieldbg;
alert ("Please input " + label_name);
return false;
} else return true;
}
if (!isNum(s)) {
field_name.focus();
field_name.style.background=fieldbg;
alert(label_name+" not valid,Please input Number!");
return false;
}
return true;
}

function chkCharNum(field_name,label_name,defaultEmpty) {
if (typeof(defaultEmpty) == "undefined") defaultEmpty = true;
var s = field_name.value;
if(isEmpty(s)) {
if (!defaultEmpty) {
field_name.focus();
field_name.style.background=fieldbg;
alert ("Please input " + label_name);
return false;
} else return true;
}
if (!isCharNum(s)) {
field_name.focus();
field_name.style.background=fieldbg;
alert(label_name+" input invalid,Please input number or letter!");
return false;
}
return true;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值