Is it possible to block past dates in an <asp:textbox textmode="Date">
?
You could use the min
attribute. If you want dynamic behavior (so that it always updates to block dates older than whatever "today" is), you can set the min
attribute in your code behind:
TextBoxArrival.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd"); //assumes an <asp:textbox> with ID="TextBoxArrival"
or use an HTML input field where you can set min
directly:
<input type="date" min="<%= DateTime.Now.ToString("yyyy-MM-dd") %>" value="2013-02-24" />
There's also a max
attribute you could use to restrict the maximum date that could be selected in the field.
Also don't forget that this is not validation. You should make sure that you perform this validation on your server and not rely on client side.