views:

674

answers:

3

Hi,

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.

+2  A: 

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.

Stan R.
A: 

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.

Cleiton
hahahaah I saw now that I gave the same answer of Sandeep from the asp.net forum.
Cleiton
A: 

For the alternate approach visit this link: http://dhondiyals.wordpress.com/2010/05/15/validate-date-in-ddmmyyyy-format/

Kailash Dhondiyal