Validating textbox for long date MM/YY/DD HH:HHAM comparevalidator ?

J

Jason

I have a textbox that I want to validate a textbox for a date like
"01/01/2000 03:00PM"

The below validates nicely for 01/01/2000.

What's the easiest way to do this in asp.net 2.0 / vb.net?


</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
<br />
<asp:comparevalidator ID=cvJobExpires Runat="server"
Operator="DataTypeCheck" Type="Date" ControlToValidate="TextBox1"
Display=Dynamic>not a valid date.</asp:comparevalidator><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>

If a regular expression validator or codebehind logic, do you have
sample code?

Thanks.
 
J

Jason

Nevermind I got it:

ValidationExpression="\d{1,2}/\d{1,2}/\d{4}\s\d{1,2}:\d{1,2}(AM|am|PM|pm)">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top