For this use the following javascript methods.
function ReturnDate(strDt)
{
var str = strDt;
var posn = str.indexOf("/");
var dd = str.substr(0,posn);
var str1 = str.substr(posn+1);
posn = str1.indexOf("/");
var strMm = str1.substr(0,posn);
if(strMm.length==1)
{
strMm="0"+ strMm;
}
var mm=strMm
var yy = str1.substr(posn+1);
if(mm=="01") mm=0;
else if(mm=="02") mm=1;
else if(mm=="03") mm=2;
else if(mm=="04") mm=3;
else if(mm=="05") mm=4;
else if(mm=="06") mm=5;
else if(mm=="07") mm=6;
else if(mm=="08") mm=7;
else if(mm=="09") mm=8;
else if(mm=="10") mm=9;
else if(mm=="11") mm=10;
else if(mm=="12") mm=11;
var ReturnDate = new Date(yy,mm,dd)
return ReturnDate;
}
function GetMonth(intMonth){
var MonthArray = new Array("01", "02", "03",
"04", "05", "06",
"07", "08", "09",
"10", "11", "12");
return MonthArray[intMonth];
}
function ValidateDates()
{
var otxtFromDate = document.getElementById('<%= txtFrom.ClientID %>')
var otxtToDate = document.getElementById('<%= txtTo.ClientID %>')
var toDate = otxtToDate.value;
var fromDate = otxtFromDate.value;
var currDate=new Date();
var currYear=currDate.getFullYear();
var currDay=currDate.getDate();
var currMonth=GetMonth(currDate.getMonth());
currDate=currDay+"/"+currMonth+"/"+currYear;
if(toDate != null && toDate != '')
{
if(ReturnDate(toDate)
otxtToDate.focus();
return false;
}
}
if(fromDate != null && toDate != null && fromDate != '' && toDate != '')
{
if(ReturnDate(fromDate)>ReturnDate(toDate))
{
otxtToDate.focus();
return false;
}
}
return true;
}