Click here to Skip to main content
14,699,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I have a control like:

<asp:TextBox ID="_txtLeadDate" runat="server"></asp:TextBox>
   <AjaxControl:CalendarExtender ID="_txtLeadDate_CalendarExtender" Format="dd/MMM/yyyy" runat="server" Enabled="True" TargetControlID="_txtLeadDate"></AjaxControl:CalendarExtender><br />
   <asp:RequiredFieldValidator ID="RequirePreDate" runat="server" ControlToValidate="_txtLeadDate" ErrorMessage="Please select a Date" ForeColor="Red" Font-Size="10px" SetFocusOnError="True"></asp:RequiredFieldValidator>

Now I am trying to add another validation that date selected should't be a past date (only current and future date). How can I achieve that. Kindly help.

1 solution

you can simply set start date as yesterday then user can't select old days. in page load do as below
protected void Page_Load(object sender, EventArgs e)
   _txtLeadDate_CalendarExtender.StartDate = DateTime.Now.AddDays(-1);   //to dissable past Date

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900