Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Date/Time Range Validator for ASP.Net

It looks like the standard asp.net 2 RangeValidator control doesn't allow times. e.g. 01/01/2008 12:00 is not accepted in my range, even though it should be valid. If I remove the time it works as expected.

Is there a validator out there that allows for date/time format?

Update

We don't have Ajax extensions. Ideally, would like a preexisting control or a regular expression to use with CustomValidator. Validation should be client side, the server validation part is easy.

Solution

We used this RegExp:

http://regexlib.com/REDetails.aspx?regexp_id=610

like image 539
B Z Avatar asked Aug 05 '26 17:08

B Z


1 Answers

You could use a custom validator and perform the check manually.

Here's a quick example or you can Google "asp.net custom validator". If you exclude the "ControlToValidate" property then you can validate against multiple fields.

like image 141
Jonathan S. Avatar answered Aug 07 '26 06:08

Jonathan S.



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!