You should use a jQuery datepicker for the following reasons:
1. No need to write code to validate users' inputs for date (that is the biggest hassle of all);
2. Easily customizable date format for display.
3. No server side round trips.
Adapt the following code to your need:
<!doctype html>
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(function() {
var format = "dd/mm/yy";
var $this = $("#datepicker");
var newDate = $this.datepicker({
dateFormat: format,
onSelect: function()
{
var newDate= $(this).datepicker('getDate');
var curDateTime = new Date();
var curDate = new Date(curDateTime.getFullYear(), curDateTime.getMonth(), curDateTime.getDate());
if (curDate > newDate ) {
alert('The new date is earlier than today');
} else if (curDate < newDate ){
alert('The new date is later than today');
} else {
alert('The new date is today');
}
}
});
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
Learn more
jqueryui.datepicker[
^]