

	//This function returns true if the entered format id mm/dd/yyyy.
	
	function checkDate(strReceived)
	{
		if(strReceived.indexOf(".")!=-1)
		{
			return false;
		}
		
		var intDay;
		var intMonth;
		var intYear;
		
		var intFirstPosition;
		var intSecondPosition;
		
		var intCountSlash=0;
		var intCountHyphen=0;
		
		for(var intCount=0;intCount<strReceived.length;intCount++)
		{
			if(strReceived.charAt(intCount)=="/")
			{
				intCountSlash++;
			}
			else if(strReceived.charAt(intCount)=="-")
			{
				intCountHyphen++;
			}
		}
		//Finding the Position of the Seperators.
		
		if ((intCountSlash==2)&&(intCountHyphen==0))
		{
			intFirstPosition=strReceived.indexOf("/")
			intSecondPosition=strReceived.lastIndexOf("/")
		}
		else if ((intCountSlash==0)&&(intCountHyphen==2))
		{
			intFirstPosition=strReceived.indexOf("-")
			intSecondPosition=strReceived.lastIndexOf("-")
		}
		else if ((intCountHyphen==1)&&(intCountSlash==1))
		{
			if(strReceived.indexOf("-")<strReceived.indexOf("/"))
			{
				intFirstPosition=strReceived.indexOf("-")
				intSecondPosition=strReceived.indexOf("/")
			}
			else
			{
				intFirstPosition=strReceived.indexOf("/")
				intSecondPosition=strReceived.indexOf("-")
			}
		}
		else
		{
			return false;
		}	
			
		//Finding the Day,Month, and Year.
		
		
		//uncomment this and comment the next two lines for dd/mm/yyyy format
		intDay=strReceived.substring(0,intFirstPosition);
		intMonth=strReceived.substring(intFirstPosition+1,intSecondPosition);
		
		//intMonth = strReceived.substring(0,intFirstPosition);
		//intDay	 = strReceived.substring(intFirstPosition+1,intSecondPosition);
		
		intYear=strReceived.substring(intSecondPosition+1);
		
		//alert(intDay);
		//alert(intMonth)
		//alert(intYear)
		
		if(strReceived.substring(intSecondPosition+1).length !=4)
		{
			return false;
		}
						
		//Checking for Proper Date(Day).
		
		if((intDay==0)||(intDay>31)||isNaN(intDay))
		{
			return false;
		}
		
		//Checking for Proper Month.
		
		if((intMonth==0)||(intMonth>12)||isNaN(intMonth))
		{
			return false;
		}
		
		//Checking for Proper Year.
		
		if((intYear==0)||isNaN(intYear))
		{
			return false;
		}
				
		/*
		
		Checking whether the day is greater than 29 the month is 2.
		
		*/
		
		if((intDay > 29)&&(intMonth==2))
		{
			return false;
		}
		
		/*
		
		Checking whether the day is 31 and the month is 4,6,9,or 11.
		(April,June,September,or November)
		
		*/
		
		if((intDay == 31)&&((intMonth==4)||(intMonth==6)||(intMonth==9)||(intMonth==11)))
		{
			return false;
		}
				
		/*
		Checking whether the day is 29, the month is 2,
		and the year is not a leap year.(Leap year checking.)
		
		1.The year which is divisible by 4 is a leap year if it is not divisible by 100.
		2.The year which is divisible by 100, and not divisible by 400 is not a leap year.
				
		*/
		
		if((intYear%4!=0)||((intYear%400!=0)&&(intYear%100==0)))
		{
			if((intDay==29)&&(intMonth==2))
			{
				return false;
			}
		}
					
		return true;
	}