views:

66

answers:

2

Hi,

I need to validate a date in a web forms application. For this I use a CompareValidator with

Operator="DataTypeCheck" Type="Date"

The problem is that this Validator doesn't work properly on Firefox with 2 digit years. ( javascript error: m[2] is undefined) With a 4 digits year it's working properly.

This problem is described also here: https://connect.microsoft.com/VisualStudio/feedback/details/355573/comparevalidator-client-side-bug-two-digit-year-in-mozilla-based-browsers-throws-js-exception

Does anyone know a nice workaround for this?

Thanks

+1  A: 

Perhaps this helps you(last post, only dataType == "Date" needed), but i havent tested it: http://forums.asp.net/t/1358621.aspx

Tim Schmelter
Hi Tim thank for your hint. In the thread you specified Rachel suggested to use a CustomValidator with a fixed java-script code from ComparedValidator. I preferred to create a new validator since I can easily reuse it through the code.
costin
A: 

My solution was to create a date validator which inherits from BaseValidator and overwrites the ControlPropertiesValid(), EvaluateIsValid() and OnPreRender(EventArgs e). If you have other ideas please shot.

costin