PDA

View Full Version : Date class automatically corrects invalid date



crbaker
22 May 2008, 11:00 PM
Hi,

I am using a DateField for date inputs and using the format 'Y-m-d', however when the user supplies a date like this one:

2008-15-15 (note: invalid months)
the DateField automatically corrects the date to: 2009-03-15.
It appears (in this case) to be adding 15 months onto 2008 - brining the result up to March the following year.

This 'feature' is part of the ExtJs Date class as when constructing a new Date class as below:
var dt = new Date('15/15/2008 00:00:00 PM GMT-0600'); // note again the invalid months
the new variable (dt) now has a date of March 15th 2009! - It should throw an invalid date exception.

Is there any way to stop this 'auto-correction' from happening?

Thanks.

evant
23 May 2008, 1:55 AM
I believe this is a "feature" of the browsers implementation of javascript, this isn't something that is Ext specific.

crbaker
23 May 2008, 1:59 AM
Yes - thanks for the reply. Since I posted my problem I came across this post:

http://extjs.com/forum/showthread.php?t=15762&highlight=date+validation

It has answered and solved my problems.