ashtame
ashtame

Reputation:

CompareValidator date format

I have an ajax calendar control that I specified the date format to be yyyy-MM-dd. Is it possible to have the comparevalidator validate that type of date sepcifically and have it fail for everything else? right now it seems to only take dd-MM-yyyy.

Thanks.

Upvotes: 1

Views: 5843

Answers (2)

Cleiton
Cleiton

Reputation: 18113

Set CultureInvariantValues="true"

from the docs:

Culture Invariant Values - When doing conversion on a compare validator's non strongly-typed properties (CompareValidator.ValueToCompare, RangeValidator.MaximumValue, RangeValidator.MinimumValue) the validator will use a culture neutral format (Date: YYYY/MM/DD, Double & Currency: US culture format) to do the conversion when CultureInvariantValues is true.


EDIT

Searching on the web, I found a similar question in another forum, see: http://forums.asp.net/t/1229615.aspx, maybe the last answer (that was gave by Mohan.Raju) can solve your problem too.

Upvotes: 1

Stan R.
Stan R.

Reputation: 16065

I assume validators use the current CultureInfo object to determine the date format.

CultureInfo.DateTimeInfo.ShortDatePattern

Try changing the page culture(MSDN).

If you don't want to go that route you can always create a custom validator.

Upvotes: 5

Related Questions