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

verify.js文件一
//****************VARIABLE DESCRIPTION*******************//
// s=字符串
// label_name = 输入框标识
// allow_len = 允许长度
// field_name = 字段名称 (document.formname.field)

//*************************************FUNCTION INCLUDED***************************************//

//chkLen(field_name, allow_len, label_name)              //校验字符串长度,汉字按2位计算    [布尔]
//chkLen(field_name, allow_len, label_name,defaultEmpty) //校验字符串长度,给定字段是否为空 [布尔]
//chkEmail(field_name,label_name)        //校验E_mail       [布尔]
//chkNum(field_name,label_name)        //校验数字串(0-9)
//chkCharNum(field_name,label_name)        //校验字符串(0-9a-zA-Z)
//chkPhone(field_name,label_name)                //校验电话(0000-0000-0000)
//chkPostCode(field_name,label_name)        //校验邮编
//chkInteger(field_name,label_name)        //校验正整数
//chkWhiteSpace(field_name,label_name)        //检验空格
//chkFloat(field_name,allow_len,dec,label_name,allow_zero)   //校验符点数
//chkFileChar(field_name,label_name,defaultEmpty)                            //校验字符串(0-9a-zA-Z,-,.)
//(dec=小数点后的位数 allow_zero=是否允许为零)
//isFloatLength (s,label_name,allow_len, dec,floatErrMes)

//******************FUNCTION HEADER**********************//
//******************FUNCTION HEADER**********************//

// BOI, followed by one or more digits, followed by EOI.
var reInteger = /^\d+$/

// BOI, followed by one or more whitespace characters, followed by EOI.
var reWhitespace = /^\s+$/

// decimal point character differs by language and culture
var decimalPointDelimiter = "."

// field bgcolor
var fieldbg="#D0D0D0";

//*****************FUNCTION MAIN**************************//

function trim(s) {
var tempStr;
tempStr = s.replace(/\s+$/g,'');
tempStr = tempStr.replace(/^\s+/g,'');
return tempStr;
}

function isEmpty(s){
return ((s == null) || (trim(s).length == 0))
}

function isNum(s) {
    var str = /^[0-9]*$/;
    return (str.test(s));
}

function isCharNum(s) {
    var str = /^[0-9a-zA-Z]*$/;
return (str.test(s));
}

//is Integer?
function isInteger (s)
{
var reInteger = /^\d+$/
if (!reInteger.test(s) || parseInt(s,10)==0)return false;
return true
}

function getTextLen(s) {
    var newlength=0;
    for(i=0;i<s.length;i++) {
       var chrInput;
       chrInput=escape(s.charAt(i));
       if(chrInput.length==6) newlength=newlength+3;
       else newlength=newlength+1;
    } //End for
    return newlength;
}


function chkSeleect(field_name,label_name) {
    for ( i = 0; i < field_name.options.length; i++ ) {
       if ( field_name.options[i].selected )  {
       if (i==0) {
   field_name.focus();
      // field_name.style.background=fieldbg;
       alert ("Please select " + label_name