
	function date_validate(dd, mm, yyyy)
	{
	   var chk    = 0;
	   var maxDay = 0;
	
	// calling function to get maximum day for this month
	maxDay = max_day(mm, yyyy);  
	
	if((dd <= 0) || (dd > maxDay))
	{ chk = 1;}
	else if((mm <= 0) || (mm > 12))
	{ chk = 1;}
	else if((yyyy <= 1800))
	{ chk = 1;} 
	
	if(chk == 1)
	{ return false;}
	else
	{ return true;}
	}
	
	// function for calculating maximum day 
	function max_day(mn, yr)
	{
	   var mDay;
	if((mn == 4) || (mn == 6) || (mn == 9) || (mn == 11))
	{ 
	mDay = 30;
	}
	else if(mn == 2)
	{
	//calling leap year function 
	mDay = isLeapYear(yr) ? 29 : 28;
	}
	else
	{
	mDay = 31;
	}
	return mDay; 
	}

	// function to check leap year
	function isLeapYear(yr)
	{
	if (yr % 100 == 0) {
	if (yr % 400 == 0) { return true; }
	}
	else {
	if ((yr % 4) == 0) { return true; }
	}
	return false;

	}