Monday, June 23, 2008

date Comparision

if(document.getElementById(FinalControlID2).value != "" && document.getElementById(FinalControlID3).value != "")
{
var sDateStart = document.getElementById(FinalControlID2).value;
var sDateEnd = document.getElementById(FinalControlID3).value;
startArr = sDateStart.split('/');

endArr = sDateEnd.split('/');

y1 = startArr[2];

m1 = startArr[1];

d1 = startArr[0];


y2 = endArr[2];

m2 = endArr[1];

d2 = endArr[0];


date1 = new Date(y1,m1,d1);
date2 = new Date(y2,m2,d2);


if (date1.getTime() > date2.getTime())

{

alert("start date should not be greater than end date.");

//document.getElementById(FinalControlID2).focus();

return false;

}

}

No comments: