I am trying to use JavaScript to validate that the date selected is not earlier than today, but when I select today's date it's showing the alert box. 

JavaScript:

```
function checkDueDate(sender, args) {
    var td = new Date(); 
    td.setMinutes(59);
    td.setSeconds(59);
    td.setHours(23);
    //to move back one day
    td.setDate(td.getDate() - 1);

    if (sender._selectedDate < td) {
        alert("You can't select day from the past! " + td + "");
        sender._selectedDate = new Date();
        // set the date back to the current date
        sender._textbox.set_Value(sender._selectedDate.format(sender._format))
    }

```

ASP.NET:

```
        <asp:TextBox ID="txtDueDate" runat="server"></asp:TextBox>
        <asp:CalendarExtender ID="txtDueDate_CalendarExtender" runat="server" 
            TargetControlID="txtDueDate" OnClientDateSelectionChanged="checkDueDate">
        </asp:CalendarExtender>

```

![Image](https://i.stack.imgur.com/RX9R8.png)