function CheckEmpty(Field, FieldTitle)
{
	if (Field.value == "")
	{
		alert("请在\"" + FieldTitle + "\"一栏中输入内容.");
		Field.focus();
		return false;
	}
		
	return true;
}
	
function CheckInteger(Field, FieldTitle)
{
	if (Field.value != "")
	{
		for (i = 0; i < Field.value.length; i++)
		{
			ch = Field.value.charAt(i);
				
			if ( (ch < '0' || ch > '9') && ch != '-' ) {
				alert("\"" + FieldTitle + "\"中只能输入数字.");
				Field.focus();
				return	false;
			}
		}
	}
		
	return true;
}
	
function CheckReal(Field, FieldTitle)
{
	if (Field.value != "")
	{
		DotNum = 0;
		for (i = 0; i < Field.value.length;  i++)
		{
			ch = Field.value.charAt(i);
				
			if ((ch < '0' || ch > '9') && ch != '.') 
			{
				alert("\"" + FieldTitle + "\"中只能输入数字.");
				Field.focus();
				return false;
			}
				
			if (ch == '.')
			{
				if (DotNum > 0) 
				{
					alert("\"" + FieldTitle + "\"中只能输入一个小数点.");
					Field.focus();
					DotNum++;
					return false;
				}
			}
		}
	}
		
	return	true;
}

function CheckMaxLength(Field, MaxLength, FieldTitle)  
{  
	if (Field.value != "")  
	{  
		if (Field.value.length > MaxLength)  
		{  
			alert("\"" + FieldTitle + "\"中输入的字符请不要超过" + MaxLength + "字符.");  
			Field.focus();  
			return false;  
		}  
	}  
			  
	return true;  
}
	  
function CheckMinLength(Field, MinLength, FieldTitle)  
{  
	if (Field.value != "")  
	{  
		if (Field.value.length < MinLength)  
		{  
			alert("\"" + FieldTitle + "\"中输入的字符请不要少于" + MinLength + "字符.");  
			Field.focus();  
			return false;  
		}  
	}  
			  
	return true;  
}  
	
function CheckOption(Field, FieldTitle) 
{
	for (i = 0; i < Field.length; i++)
		if (Field[i].checked)
			return true;
				
	alert("请选择\"" + FieldTitle + "\"中的值.");
	return false;
}
	
function Checkselect(Field, FieldTitle) 
{
	if (Field.options[Field.selectedIndex].value=="")
	{
		alert("请选择\"" + FieldTitle+"\"" );
		Field.focus();
		return false;
	}
		
	return true;
}

	//此函数用于判断Email地址是否正确
function CheckEmail(Field)
{
   // there must be >= 1 character before @, so we
   // start looking at character position 1
   // (i.e. second character)
   var i = 1;
   var len = Field.value.length;
	if (len > 50)
	{
		window.alert("email地址长度不能超过50位!");
		return false;
	}
	pos1 = Field.value.indexOf("@");
	pos2 = Field.value.indexOf(".");
	pos3 = Field.value.lastIndexOf("@");
	pos4 = Field.value.lastIndexOf(".");
	//check '@' and '.' is not first or last character
	if ((pos1 <= 0)||(pos1 == len-1)||(pos2 <= 0)||(pos2 == len-1))  
	{
		window.alert("请输入有效的E-mail地址！");
		Field.focus();
		return false;
	}
	else
	{
		//check @. or .@
		if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) 
		  || ( pos1 != pos3 )  //find two @
		  || ( pos4 < pos3 ) ) //. should behind the '@'  		
		{
			window.alert("请输入有效的E-mail地址！");
			return false;
		}
	}
	return true;
}
	
function CheckMustLength(Field, MustLength, FieldTitle)  
{  
		if (Field.value.length != MustLength)  
		{  
			alert("\"" + FieldTitle + "\"中输入的值必须是" + MustLength + "位.");  
			Field.focus();  
			return false;  
		}  
	return true;  
}  
	  
function CheckIntRange(field,prompt,min,max) {  
	if ( ! CheckInteger(field,prompt) )  
		return	false;  
	ival = parseInt(field.value);  
	if ( ival < min || ival > max ) {  
		alert(prompt + " 只能为 " + min + " 到 " + max + " 之间的数");  
		field.focus();  
		return	false;  
	}  
	return	true;  
}  


//列表框选择值
function SelectValue(objSelect,strValue){
	if (strValue=="") return;
	for(i=0;i<objSelect.options.length;i++){
		if(objSelect.options[i].value==strValue){
			objSelect.options[i].selected=true;
			break;
		}
	}
}

//单选框选择值
function RadioValue(objSelect,strValue){
	if (strValue=="") return;
	for(i=0;i<objSelect.length;i++){
		if(objSelect[i].value==strValue){
			objSelect[i].checked=true;
			break;
		}
	}
}

//复选框选择值
function CheckValue(objSelect,strValue){
	if (strValue=="") return;
	if(objSelect.value==strValue){
		objSelect.checked=true;
	}
}

//复选框选择值
function CheckValues(objSelectList,strValue){
	if (strValue=="") return;
	if (objSelectList.length==null){
		if(strValue.indexOf(objSelectList.value)>=0){
			objSelectList.checked=true;
		}
	}
	else{
		for(i=0;i<objSelectList.length;i++){
			if(strValue.indexOf(objSelectList[i].value)>=0){
				objSelectList[i].checked=true;
			}
		}
	}
}

//复选框选择值
function CheckValue1(objSelect,strValue){
	if (strValue=="") return;
	if(objSelect.value==strValue){
		objSelect.checked=true;
	}
	else{
		objSelect.checked=false;
	}
}
