
//*****************************************************
//* FunctionName:	

//* Purpose:		检查数字：1234
//* Date:			2001/11/30
//* Modified:
//* Parameter1:		控件对象
//* Return:			true/false
//* Example:		isNumber(document.MyForm.Num.value)
//*****************************************************
function isNumber( data )
{
  var tempStr = "-0123456789" ;
  var thisChar ;
  for( var i=0 ; i < data.length ; i++ )
  {
	thisChar = data.substring( i, i+1 ) ;
	if ( tempStr.indexOf(thisChar, 0) == -1 )
	{
	  return( false ) ;
	}
  }
  return( true ) ;
}

//******************************************************************
//* FunctionName:	isPointNum()
//* Purpose:		"123.45"检查小数
//* Date:			2002/02/09
//* Modified:
//* Parameter1:		控件的值，数值的长度，小数点后的长度
//* Return:			true/false
//* Example:		isPointNum(document.MyForm.number.value,5,2)
//******************************************************************
function isPointNum( usngNum,uintBefPoint,uintAftPoint )
{
    if(isPoint(usngNum) == true){
	 if(usngNum.indexOf(".")!="-1"){
	 	if(usngNum.indexOf(".")==usngNum.lastIndexOf(".")){
		    if(usngNum.indexOf(".") == 0){
		    	return false ; 	
		    }else{
			var wstrBefPoint  = usngNum.substring(0,usngNum.indexOf(".")); 
			var wstrAftPoint= usngNum.substring(usngNum.indexOf(".")+1); 
			if( wstrBefPoint.substring(0,1) == 0 && wstrBefPoint.length > 1){
			    return false ;	    	
			}else{
			    if(wstrAftPoint.length == 0 ){
			    	return false;	
			    }else{
				if(wstrBefPoint.length <= uintBefPoint-uintAftPoint && wstrAftPoint.length <= uintAftPoint){
				    return true ;
				}else{
				    return false;
				}
			    }
			}
		    }
		}else{
		    return false ;
		}
	 }else{
	    	if(usngNum.length>uintBefPoint-uintAftPoint){
	    		return false ;	
	    	}else{
	    		return true ;
	    	}
	}
     }else{
     	return false ;
     }

}

//*****************************************************
//* FunctionName:	isPoint()
//* Purpose:		检查有小数点和负号
//* Date:			2002/02/04
//* Modified:
//* Parameter1:		控件的值
//* Return:			true/false
//* Example:		isPoint(document.MyForm.Num.value)
//*****************************************************
function isPoint( data )
{
  var tempStr = "-0123456789." ;
  var thisChar ;
  for( var i=0 ; i < data.length ; i++ )
  {
	thisChar = data.substring( i, i+1 ) ;
	if ( tempStr.indexOf(thisChar, 0) == -1 )
	{
	  return( false ) ;
	}
  }
  return( true ) ;
}

//删除空格
//参数：document.MyForm.Num
function delLastSpace( strField ){
    if( strField.value.match("[ ]$") != null ){
        while(1){
            if( strField.value.match("[ ]$") == null )    break;
            strNew = strField.value.substring(0,(strField.value.length-1));
            strField.value = strNew;
        }
    }

}

//*****************************************************
//* FunctionName:	isNull()
//* Purpose:		检查空
//* Date:			2001/11/30
//* Modified:
//* Parameter1:		控件对象
//* Return:			true/false
//* Example:		isNull(document.MyForm.Num)
//*****************************************************
function isNull(inField){
  delLastSpace(inField);
  if (inField.value=="" || inField.length==0)
    return false;
  else
    return true;
}

//*****************************************************
//* FunctionName:	getLength()
//* Purpose:		得到控件值的长度
//* Date:			2001/11/30
//* Modified:
//* Parameter1:		控件值
//* Return:			int
//* Example:		getLength(document.MyForm.Text1.value)
//*****************************************************
function getLength(data)
{
	var len = 0 ;
	len = data.length ;
	return ( len ) ;
}

//*****************************************************
//* FunctionName:	getLengthB()
//* Purpose:		得到控件值的长度(字节)
//* Date:			2001/11/30
//* Modified:
//* Parameter1:		控件值
//* Return:			int
//* Example:		getLengthB(document.MyForm.Text1.value)
//*****************************************************
function getLengthB(data)
{
  var i,cnt = 0;
  for(i=0; i< data.length; i++)
  {	
  	if (checkFullHalf(data.charAt(i))){
  		cnt+=2;
  	}else{
		if (escape(data.charAt(i)).length >= 4 )
		{
		  if (escape(data.charAt(i)) >= "%uFF65" && escape(data.charAt(i)) <= "%uFF9F")
		  {
			cnt++;
		  }
		  else
		  {
			cnt+=2;
		  }
		}
		else
		{
		  cnt++;
		}
	}
   }
  return cnt;
}

//*****************************************************
//* FunctionName:	checkFullHalf()
//* Purpose:		
//* Author:		
//* Date:		2003/07/15
//* Modified:
//* Parameter1:		控件值
//* Return:		true/false
//* Example:		checkFullHalf(document.MyForm.Text1.value)
//*****************************************************

function checkFullHalf(data) {
	
  var Hankan = ["值"];
  var temp = "";
  for (var i = 0; i < data.length; i++) {
   	temp = data.substring(i, i + 1);
   	for (var j = 0; j < Hankan.length; j++) {
  		if (temp==Hankan[j]) {
     		return true;
   		}
    }
  }
  return false;		
}
//*****************************************************
//* FunctionName:	isDate()
//* Purpose:		"YYYY-MM-DD"日期合法性
//* Date:			2002-02-09
//* Modified:
//* Parameter1:		日期"YYYY-MM-DD"
//* Return:			true/false
//* Example:		isDate(document.MyForm.Num.value)
//*****************************************************
function isDate( ustrDate )
{
	if(ustrDate.length != 0){
	    //if(ustrDate.length != 8){
	    //	return false ;
	    //} 
		var myYear = parseInt(ustrDate.indexOf('-'));
		var myDay = parseInt(ustrDate.lastIndexOf('-'))+1
		
	    var wstrYear  = ustrDate.substring(0,myYear); 
	    var wstrMonth = ustrDate.substring(myYear+1,myDay-1); 
	    var wstrDay   = ustrDate.substr(myDay); 
	    
	    var wstrDate  = new Date(wstrYear+"/"+wstrMonth+"/"+wstrDay);
		
	    if(wstrDate.getFullYear() == wstrYear && wstrDate.getMonth()+1==wstrMonth && wstrDate.getDate() == wstrDay){
			return true ;	    	
	    }else{
	    	return false ;
	    }
	}else{
		return true ;
	}
}

//*****************************************************
//* FunctionName:	isDateTime()
//* Purpose:		"YYYY-MM-DD HH:MM:SS"日期时间合法性
//* Date:			2002-02-09
//* Modified:
//* Parameter1:		日期"YYYY-MM-DD HH:MM:SS"
//* Return:			true/false
//* Example:		isDateTime(document.MyForm.Num.value)
//*****************************************************
function isDateTime( ustrDate )
{
	if(ustrDate.length != 0){
	    //if(ustrDate.length != 8){
	    //	return false ;
	    //} 
		var myYear = parseInt(ustrDate.indexOf('-'));
		var myDay = parseInt(ustrDate.lastIndexOf('-'))+1
		var myBlank = parseInt(ustrDate.indexOf(' '));
		
	    var wstrYear  = ustrDate.substring(0,myYear); 
	    var wstrMonth = ustrDate.substring(myYear+1,myDay-1); 
	    var wstrDay   = ustrDate.substring(myDay,myBlank); 
	    var wstrTime  = ustrDate.substr(myBlank);
	    
	    var myHour = parseInt(wstrTime.indexOf(':'));
	    var mySecond = parseInt(wstrTime.lastIndexOf(':'))+1;
	    var wstrHour  = wstrTime.substring(0,myHour); 
	    var wstrMinute = wstrTime.substring(myHour+1,mySecond-1); 
	    var wstrSecond   = wstrTime.substr(mySecond); 
	    
	    var wstrDate  = new Date(wstrYear+"/"+wstrMonth+"/"+wstrDay);

	    if(wstrDate.getFullYear() == wstrYear && wstrDate.getMonth()+1==wstrMonth && wstrDate.getDate() == wstrDay && wstrHour<24 && wstrMinute<60 && wstrSecond<60){
			return true ;	    	
	    }else{
	    	return false ;
	    }
	    
	    
	}else{
		return true ;
	}
}

