BeanSoftware Logo

ASP.NET Database Search Control

    Write For Us

How To Validate If TextBox Contains A Valid Date?

To check is string a valid date you can use CompareValidator. Let say you have one TextBox control on web form, named txtOnlyValidDate. Add CompareValidator control from toolbox and set its ControlToValidate property to txtOnlyValidDate. Set Operator property to DataTypeCheck and set Type property to Date, like in code bellow:

<asp:TextBox ID="txtOnlyValidDate" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToValidate="txtOnlyValidDate" ErrorMessage="CompareValidator"
Operator="DataTypeCheck" Type="Date"></asp:CompareValidator>

Related articles:

1. Media Player ASP.NET Control - C# Source Code

FAQ toolbar: Submit FAQ  |  Tell A Friend  |  Add to favorites  |  Feedback

Copyright © 2002-2008 Bean Software. All rights reserved.