/* 
CheckForEmpty(objField,strLabel,bMandatory)

CheckForEmail(objField,strLabel,bMandatory)

CheckForEmptyCombo(objField,strLabel,bMandatory)

CheckForEmptyCheckBox(objField,strLabel,bMandatory)

CheckMaxLength(objField,strLabel,intMaxLen,bMandatory)

CheckMinLength(objField,strLabel,intMinLen,bMandatory)

CheckForCompareFields(objField1,objField2,strLabel)

CheckValidDate(objDay,objMonth,objYear)

CheckForDoctorCategory(objField1,objField2,objField3,strLabel,bMandatory)
*/


//Check for empty
function CheckForEmpty(objField,strLabel,bMandatory)
{
	var strValue;
	strValue =	objField.value;
	if (bMandatory==true)
	{
		if(strValue=="")
		{
			alert("Please Enter the "+strLabel)
			objField.focus();
			return false;
		}
	}
	return true;
}

//Check for email
function CheckForEmail(objField,strLabel,bMandatory)
{
	var strValue;
	strValue = objField.value;
	if (bMandatory==true)
	{
		if(strValue =="")  
		{
			alert("Please Enter the "+strLabel)
			objField.focus();
			return false;
		}
		else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(strValue)))
		{
			alert("Please Enter valid "+strLabel)
			objField.focus();
			return false;
		}
	}
	return true;
}

//Check for EmptyCombo
function CheckForEmptyCombo(objField,strLabel,bMandatory)
{
	var strValue;
	strValue	=	objField.value;
	if (bMandatory==true)
	{
		if(strValue=="-1")
		{
			alert(strLabel)
			objField.focus();
			return false;
		}
	}
	return true;
}

//Check for EmptyCombo
function CheckForEmptyCheckBox(objField,strLabel,bMandatory)
{
	if (bMandatory==true)
	{
		if(objField.checked == false)
		{
			alert("Please choose the "+strLabel)
			objField.focus();
			return false;
		}
	}
	return true;
}

// Check  Maximum length of field
function CheckMaxLength(objField,strLabel,intMaxLen,bMandatory)
{
	var strValue;
	var intLength;
	
	strValue = objField.value;
	intLength = strValue.length;
	
	if (bMandatory==true)
	{
		if(strValue =="")  
		{
			alert("Please Enter the "+strLabel)
			objField.focus();
			return false;
		}
		else if (intMaxLen!="")
		{
			if(intLength>intMaxLen)
			{
				alert("Maximum Length allowed for "+strLabel+" is "+intMaxLen)
				objField.focus();
				return false;
			}
		}
	}
	return true;
}

// Check Minimum length of field
function CheckMinLength(objField,strLabel,intMinLen,bMandatory)
{
	var strValue;
	var intLength;
	
	strValue = objField.value;
	intLength = strValue.length;
	
	if (bMandatory==true)
	{
		if(strValue =="")  
		{
			alert("Please Enter the "+strLabel)
			objField.focus();
			return false;
		}
		else if (intMinLen!="")
		{		
			if(intLength < intMinLen)
			{
				alert("Minimum Length of "+strLabel+" must be "+intMinLen)
				objField.focus();
				return false;
			}
		}
	}
	return true;
}


// Check Minimum and Maximum length of field
function CheckForCompareFields(objField1,objField2,strLabel)
{
	if (objField1.value != objField2.value)
	{
		alert(strLabel)
		objField1.focus()
		return false;
	}
	return true;
}

//Check the valid Date
function CheckValidDate(objDay,objMonth,objYear)
{
	var DateVal = objMonth + "/" + objDay + "/" + objYear;
	var dt = new Date(DateVal);
	if(dt.getDate()!=objDay)
	{
		alert("Please select valid date");
		return false;
	}
	else if(dt.getMonth()!=objMonth-1)
	{
		alert("Please select valid date");
		return false;
	}
	else if(dt.getFullYear()!=objYear)
	{
		alert("Please select valid date");
		return false;
	}
	return true;
}


