<html>
<head>
<title>compare two dates in javascript dd/mm/yyyy.</title>
<script>
function OnCheck() {
var d_Date = document.getElementById("txtDate").value.split("/");
var txtDate = new Date(d_Date[2], d_Date[1] - 1, d_Date[0]).setHours(0, 0, 0, 0);
var currentDate = new Date().setHours(0, 0, 0, 0);
if (txtDate - currentDate == 0) {
alert('Equal to Current Date');
}
else if (txtDate - currentDate > 0) {
alert('greater than the current date');
}
else if (txtDate - currentDate < 0) {
alert('Less then the current Date');
}
}
</script>
</head>
<body>
<div>
<input id="txtDate" type="text" name="Date" value="28/04/2021" />
<button id='btnCheck' onclick='OnCheck()'>Check </button>
</div>
</body>
</html>