<html>
<head>
<title>Compare Dates</title>
<Script>
function CompareDates()
{
var str1 = document.getElementById(“fromdate”).value;
var str2 = document.getElementById(“todate”).value;
var dt1 = parseInt(str1.substring(0,2),10);
var mon1 = parseInt(str1.substring(3,5),10);
var yr1 = parseInt(str1.substring(6,10),10);
var dt2 = parseInt(str2.substring(0,2),10);
var mon2 = parseInt(str2.substring(3,5),10);
var yr2 = parseInt(str2.substring(6,10),10);
mon1=(mon1-1);
mon2=mon2-1;
var date1 = new Date(yr1, mon1, dt1);
var date2 = new Date(yr2, mon2, dt2);
if(date2 > date1)
{
alert(“date2 big”);
}
else if(date2 < date1)
{
alert(“date1 big”);
//document.form1.submit();
}
else
{
alert(“Same or confusing”);
}
}
</Script>
</head>
<body bgcolor=”#FFFFFF” text=”#000000″>
<form name=”form1″ method=”post” action=”">
<input type=”text” name=”fromdate” id=”fromdate” value=”20/10/2005″>
<input type=”text” name=”todate” id=”todate” value=”19/10/2005″>
<input type=”button” value=”compare dates” onclick=”CompareDates()”>
</form>
</body>
</html>
Share on FacebookPage views:2288