471,595 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,595 software developers and data experts.

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

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.

Oct 22 '06 #1
1 1868
Nevermind I got it:

ValidationExpression="\d{1,2}/\d{1,2}/\d{4}\s\d{1,2}:\d{1,2}(AM|am|PM|pm)">
Jason wrote:
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.
Oct 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by John | last post: by
11 posts views Thread by tshad | last post: by
1 post views Thread by R.A.M. | last post: by
5 posts views Thread by Samuel Shulman | last post: by
1 post views Thread by =?Utf-8?B?Ym9iYnk=?= | last post: by
reply views Thread by =?Utf-8?B?VmFuY291dmVyTWlrZQ==?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.