Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time validation using CompareValidator

As a (sorta) follow on from the following question - CustomValidator time c#.net - I would like to know if it is possible to use the CompareValidator to validate a time in a ASP.NET textbox?

I have attempted the following

<asp:CompareValidator ID="CompareValidator2" Operator="DataTypeCheck" 
ControlToValidate="txtTime" runat="server" ErrorMessage="* Valid time is required"      
Type="Date" Display="Dynamic" ForeColor="Red"></asp:CompareValidator>

I assumed this would work since DateTime supports (obviously) both date and times but the validator continues to fail validation with valid inputs.

So, is it possible to validate time using the CompareValidator or is a RegularExpression or Custom Validator required?

like image 478
Maxim Gershkovich Avatar asked Dec 11 '25 15:12

Maxim Gershkovich


1 Answers

This looks like a duplicate post as seen here.

The anser was from the post was.

"This appearently cannot be done.

For the record; I used a custom validator..."

like image 159
Jethro Avatar answered Dec 14 '25 05:12

Jethro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!