function verifyDate(textObj){
  var tmpDateValue = textObj.value;
  var tmpLength = tmpDateValue.length;
  if (tmpLength == 0){
    return true; 
  }
  for (var i = 0; i < tmpLength;i++){
    aChar = tmpDateValue.substring(i,i+1);
    if(aChar != "-" && (aChar < "0" || aChar > "9")) {
      alert ("请按照格式输入日期(yyyy-mm-dd)。");
      textObj.focus(this);
      textObj.select(this);
      return false;
    }
  }
  if ((tmpLength < 8 || tmpLength > 10) && tmpLength != 0) {
    alert ("请按照格式输入日期(yyyy-mm-dd)。");
      textObj.focus(this);
      textObj.select(this);
      return false;  
  }
  for (var j= 0; j < 4;j++){
    aChar = tmpDateValue.substring(j,j+1);
    if(aChar < "0" || aChar > "9") {
      alert ("请按照格式输入日期(yyyy-mm-dd)。");
      textObj.focus(this);
      textObj.select(this);
      return false;  
    }
  }
  if (tmpDateValue.substring(4,5) != "-" || tmpDateValue.substring(5,6) == "-"){
    alert ("请按规定格式输入日期(yyyy-mm-dd)。");
    textObj.focus(this);
    textObj.select(this); 
    return false;
  
  }
  if (tmpLength == 8){
    if (tmpDateValue.substring(6,7) != "-" || tmpDateValue.substring(7,8) == "-" ){
      alert ("请按规定格式输入日期(yyyy-mm-dd)。");
      textObj.focus(this);
      textObj.select(this); 
      return false;
    } 
  }
  
  if (tmpLength == 9){
    if (tmpDateValue.substring(8,9) == "-" ){
      alert ("请按规定格式输入日期(yyyy-mm-dd)。");
      textObj.focus(this);
      textObj.select(this); 
      return false;    
    }   
  }
  
  if (tmpLength == 10){
    if (tmpDateValue.substring(7,8) != "-" || tmpDateValue.substring(6,7) == "-" || tmpDateValue.substring(8,9) == "-" || tmpDateValue.substring(9,10) == "-" ){
      alert ("请按规定格式输入日期(yyyy-mm-dd)。");
      textObj.focus(this);
      textObj.select(this); 
      return false;    
    }   
  }
  var count=0;
  for (var k = 0; k < tmpLength;k++){
    aChar = tmpDateValue.substring(k,k+1);
    if(aChar == "-") {
        count++;
    }
  }
  if (count!=2){
    alert("请按照格式输入日期!(yyyy－mm-dd)");
    textObj.focus(this);
    textObj.select(this);
    return false;
  
  }
  return true;
}
//javascript支持Number(obj),非数字返回NaN
function isFloat(lv_input)
{
	if(lv_input!="0.00"){
		if(lv_input == parseFloat(lv_input)+""){
			return true;
		}else{
			lv_input = lv_input.replace(/　/g," ") + "0";
			lv_input = lv_input.replace(".0","0");
			lv_input = lv_input.replace("00","0");
			var nu_input = parseFloat(lv_input)+"";
			alert(nu_input+":"+lv_input);
			if (!isNaN(nu_input) && nu_input.length==lv_input.length){
				return true;
			}else{return false;}
		}
	}else{return true;}
}


function ObjIsEmpty(textObj)
{
	if (textObj.value.length==0 )
	{
		textObj.focus(this);
		textObj.select(this);
		alert("标注红星号的字段不能为空");
		return true;
	}
	else
	{return false;}
}



function isEmpty (str) {
	if ((str==null)||(str.length==0)) return true;
	else return(false);
}

function isEmail (theStr) {
	var atIndex = theStr.indexOf('@');
	var dotIndex = theStr.indexOf('.', atIndex);
	var flag = true;
	theSub = theStr.substring(0, dotIndex+1)

	if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
	{	return(false); }
	else { return(true); }
}



//名字输入格式控制
function isName(s)
{
	var patrn=/^[^`~!@#$%^&*()+=|\\\[\]\{\}:;\'\"\,.<>/? 　]{1,20}$/;
	if (!patrn.exec(s)) return false
	return true
}

//function isSearch(s)
//{
//	var patrn=/^[^`~!@#$%^&*()+=|\\\[\]\{\}:;\'\"\,.<>/? 　]{1,20}$/;
//	if (!patrn.exec(s)) return false
//	return true
//}
function isPasswd(s)
{
	var patrn=/^(\w){4,16}$/;
	if (!patrn.exec(s)) return false
	return true
}


/*
 * 函数：去除字符串首尾空格
 * 参数：strValue 字符串
 * 返回：去除首尾空格后的字符串
 */
function Trim(strValue)
{
	var objRegExp = /^(\s*)$/;

    // Check for all spaces
    if (objRegExp.test(strValue)) 
    {
       strValue = strValue.replace(objRegExp, '');
       if( strValue.length == 0)
          return strValue;
    }
    
	// Check for leading & trailing spaces
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if (objRegExp.test(strValue)) 
	{
		//remove leading and trailing whitespace characters
		strValue = strValue.replace(objRegExp, '$2');
	}
	return strValue;
}

/*
 * 函数：计算字符串长度
 * 参数：s 字符串
 * 输出：字符串长度
 */
function strLength(s)
{
	var l=s.length;
	var n=l

	for (var i=0;i<l;i++)
	{
		if (s.charCodeAt(i)<0||s.charCodeAt(i)>255) n++
	}
	return n		
}

/*
 * 函数：检测字符串是否全由中文组成
 * 参数：s 字符串
 * 返回：true|false
 */
function isChinese(s){
var ret=true;
for(var i=0;i<s.length;i++)
ret=ret && (s.charCodeAt(i)>=10000);
return ret;
}

/*
 * 函数：检测Email格式是否正确
 * 参数：theStr 字符串
 * 输出：true/false
 * 调用：
 */
function isEmail (theStr) {
    var atIndex = theStr.indexOf('@');
    var dotIndex = theStr.indexOf('.', atIndex);
    var flag = true;
    theSub = theStr.substring(0, dotIndex+1)

    if ((atIndex < 1)||(atIndex != theStr.lastIndexOf('@'))||(dotIndex < atIndex + 2)||(theStr.length <= theSub.length)) 
    {
    	return false;
    }
	else
	{ 
		return true;
	}
}

/*
 * 函数：检测字符串是否全由数字组成
 * 参数：s 字符串
 * 返回：true|false
 */
function isDigit(s)
{
    var patrn=/^[0-9]+$/;
    if (!patrn.exec(s)) return false
    return true
}

/*
 * 函数：检测字符串是否整数
 * 参数：s 字符串
 * 返回：true|false
 */
function isInt(s)
{
	var patrn=/^[0-9]+$/;
    if ( patrn.exec(s) && (s < 32767) )	return true
	return false
}

function isReal (theStr, decLen) {
    var dot1st = theStr.indexOf('.');
    var dot2nd = theStr.lastIndexOf('.');
    var OK = true;
    
    if (isEmpty(theStr)) return false;

    if (dot1st == -1) {
        if (!isInt(theStr)) return(false);
        else return(true);
    }
    
    else if (dot1st != dot2nd) return (false);
    else if (dot1st==0) return (false);
    else {
        var intPart = theStr.substring(0, dot1st);
        var decPart = theStr.substring(dot2nd+1);

        if (decPart.length > decLen) return(false);
        else if (!isInt(intPart) || !isInt(decPart)) return (false);
        else if (isEmpty(decPart)) return (false);
        else return(true);
    }
}