Validation of future date using compare validator in ASP.Net

In .aspx file

<asp:TextBox ID="TextBoxOrderDate" runat="server" Width="220"  MaxLength="10"></asp:TextBox>

<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtenderDate" runat="server"
                TargetControlID="TextBoxOrderDate" WatermarkText="MM/DD/YYYY">
            </asp:TextBoxWatermarkExtender>

Add here css class in  WatermarkCssClass property.

<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/calendaricon.png" />
            <asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBoxOrderDate"
                Format="MM/dd/yyyy" PopupButtonID="ImageButton1">
            </asp:CalendarExtender>
This compare validator is used to check valid date format.
<asp:CompareValidator ID="CompareValidator2" runat="server" ErrorMessage="Invalid date format."
                ValidationGroup="AddRecord" Display="None" ForeColor="Red" ControlToValidate="TextBoxOrderDate"
                Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>
            
This compare validator is used to check future date.
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Date must be less than or equal to the current date."  ValidationGroup="AddRecord" Display="None" ForeColor="Red" ControlToValidate="TextBoxOrderDate"
                Operator="LessThanEqual" Type="Date"></asp:CompareValidator>

Add validation summary control to display the error message.

<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="BulletList"
            ShowSummary="false" HeaderText="" ValidationGroup="AddRecord" ShowMessageBox="true" />

Write code in the .cs file
Protected void Page_Load(object sender, EventArgs e)
{
CompareValidator1.ValueToCompare = DateTime.Now.ToString("MM/dd/yyyy");
}