Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Validation Control in Web Form - mm/dd/yyyy 1

Status
Not open for further replies.

net123

Programmer
Joined
Oct 18, 2002
Messages
167
Location
US
I have a .aspx page in which there are form fields to search by and upon search button click, a datagrid with results is displayed below.

I have a date validation control:

<asp:comparevalidator id=&quot;Comparevalidator&quot; Text=&quot;Date must be in mm/dd/yyyy form!&quot; Runat=&quot;server&quot; Type=&quot;Date&quot; Operator=&quot;DataTypeCheck&quot; Display=&quot;Dynamic&quot; ControlToValidate=&quot;txtMyDate&quot; ErrorMessage=&quot;Date in wrong format&quot; ></asp:comparevalidator>
[/blue]

But this control allows dates in the following format: mm/dd/yyyy and m/d/yyyy, but I would like to create a custom validation control that only accepts mm/dd/yyyy dates. I have been having trouble implementing this.

Thank you in advance for your assistance.
 
You could use:
<asp:RegularExpressionValidator id=&quot;revInstallDate&quot; runat=&quot;server&quot; Width=&quot;184px&quot; EnableClientScript=&quot;True&quot; Display=&quot;Dynamic&quot; ValidationExpression=&quot;\d{2}/\d{2}/\d{4}&quot; ControlToValidate=&quot;tbInstallDate&quot; ErrorMessage=&quot;Please use format of mm/dd/yyyy &quot;></asp:RegularExpressionValidator></TD>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top