PDA

View Full Version : Funky behaviors and rollovers: not button, but on dates



JSCoder
8 Jul 2009, 3:34 AM
Ok, the EXTjs dateField is funky. Just like when I don't set sdf.setLenient(false) in Java, I suffer from all these problems - rollover, laxity in checking, the same thing is translating to Ext.

In my dateField:
if I enter 99/99/9999, it rolls over to 06/07/10007 on blur!
if I enter 12/12/, it becomes 12/12/2009 on blur!
if I enter 1/1/1, it becomes 01/01/2001
if I enter 00, it becomes today's date!

I seriously do not need these behaviors. Is there a way I can turn these assistive features off?

Animal
8 Jul 2009, 4:05 AM
http://extjs.com/deploy/dev/docs/?class=Date&member=useStrict

JSCoder
8 Jul 2009, 4:24 AM
I'm using useStrict in a wrong context. I know, this doesn't apply to the dateField, but it applies to Date, and the code below is wrong (because it's not working). How can I specify the same correctly to Ext?


Ext.QuickTips.init();

var dateBoxes = Ext.DomQuery.select("input.date");
var today = (new Date()).clearTime();

Ext.each(dateBoxes, function(item, id, all){
var cl = new Ext.form.DateField({
allowBlank : false,
applyTo: item,
hideTrigger: (item.readOnly || item.disabled),
minValue: today,
validationDelay: 1,
maskRe: /\d|\//,
useStrict: true
});
});

Animal
8 Jul 2009, 4:26 AM
Er, the API doc link?

JSCoder
8 Jul 2009, 4:39 AM
Er, the API doc link?

I looked at the member useStrict. I tried setting it globally, it didn't work. parseFunction was confusing as well. Ok, I'm feeling seriously dumb (maybe I am), but can you look at the small code fragment and tell me what the right way of achieving that would be?

Animal
8 Jul 2009, 4:47 AM
How did you try setting it?

Animal
8 Jul 2009, 4:48 AM
Also, I think it was a late addition. Possibly only in the 3.0 final release.

JSCoder
8 Jul 2009, 5:14 AM
Like this:



var dateBoxes = Ext.DomQuery.select("input.date");
var today = (new Date()).clearTime();

Ext.each(dateBoxes, function(item, id, all){
var cl = new Ext.form.DateField({
allowBlank : false,
applyTo: item,
hideTrigger: (item.readOnly || item.disabled),
minValue: today,
validationDelay: 1,
maskRe: /\d|\//,
useStrict: true
});
});

JSCoder
8 Jul 2009, 9:12 PM
Any clues on how I can prevent these assistive features? (Automatic date rollover, completion etc.?)

Animal
8 Jul 2009, 9:25 PM
The link linked to the Date object, did it not?

JSCoder
8 Jul 2009, 10:05 PM
Following that link, I used a global setting like this:

Date.useStrict = true;

Now, when I enter 99/99/9999 into my dateField, extJS still converts it to 06/07/10007 instantly. It was this assistive behavior which I wanted to disable.

Animal
8 Jul 2009, 11:20 PM
If that doesn't work, it could be an Ext bug.

Animal
8 Jul 2009, 11:24 PM
Or you are using an old release of Ext, because it does work:

http://i131.photobucket.com/albums/p286/TimeTrialAnimal/nodatebug.jpg