日期:2014-05-16  浏览次数:20436 次

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,