Hi,
Hope you are entering your date in dd/MM/yyyy format. So here is the sample code for the solution to your problem.
Place a TextBox in your .aspx page like this.
<asp:TextBox ID="txtDate" runat="server" Width="100px" onblur="checkDate(this.value);"></asp:TextBox>
Place the below script in your .aspx page
<script type="text/javascript" language="javascript">
function checkDate(input) {
var today = new Date();
var todayFormat = today.format("MM/dd/yyyy");
var endDate = formatDate(input);
if (endDate > todayFormat) {
alert("Entered date must be earlier than or equal to current date!");
}
}
function formatDate(input) {
var datePart = input.match(/\d+/g);
var day = datePart[0]
var month = datePart[1]
var year = datePart[2];
var myDate = month + '/' + day + '/' + year;
return myDate;
}
</script>
Hope this will solve your problem. Please let me know if you face any issues.
Regards,
Manoj