Date Validation in ASP.NET

Matt Berther bio photo By Matt Berther Comment

Ever have the need for a user to enter a date into a textbox, but not sure how to validate that they actually did?

<asp:CompareValidator id="dateValidator" runat="server"
  Type="Date" Operator="DataTypeCheck" ControlToValidate="dateTextbox"
  ErrorMessage="Please enter a valid date.">
</asp:CompareValidator>

This beats the heck out of writing my own code to do this, and surely this is better tested as well. ;)