views:

6179

answers:

2

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

A: 

This is done with AJAX, which should serve your purposes.

MaskedEdit Demonstration

websch01ar
Sorry, we dont' have the ajax extensions
B Z
+1  A: 

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.

Jonathan S.
Do you have regex that can do this? I was hoping I wasn't the first to come across this problem.
B Z
I don't have one off the top of my head. I've used regexes from http://regexlib.com in the past with success. If you are just matching a string for the correct date format there should be one there. This one looks like it might fit: http://regexlib.com/REDetails.aspx?regexp_id=610
Jonathan S.