-
9 Jul 2009 3:30 AM #1
[CLOSED][3.0.0] Date parsing and formatting not turned off.
[CLOSED][3.0.0] Date parsing and formatting not turned off.
On a form dateField, parsing is NOT fully turned off when using Date.useStrict = true
Some of it is turned off, but the cases: 1/1/1, 2/2/2 i.e. n/n/n are not turned off. I'm
guessing more corner cases of various formats will be there.
1/1/1 gets formatted into 01/01/2001 and so on.
Code:Date.useStrict = true; 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 : true, applyTo: item, hideTrigger: (item.readOnly || item.disabled), minValue: (item.readOnly || item.disabled)?'01/01/0001':today, validationDelay: 40, maskRe: /\d|\//, useStrict: true }); cl.validate(); });
-
9 Jul 2009 4:43 AM #2
what do you mean by "not turned off"?
as long as your date string matches either the format config or any of the other formats in the altFormats config, it will be parsed.
1/1/1 and 2/2/2 are both valid date strings.
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
9 Jul 2009 4:53 AM #3
to add on:
since 1/1/1 and 2/2/2 are both valid date strings (i.e. they match either the format config or one of the date formats in the altFormats config for the datefield), they will be parsed according to the conditions stipulated in the docs for parseDate.
i.e. "The defaults hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond) which cannot be found in the passed string. If a corresponding default date value has not been specified in the defaults hash, the current date's year, month, day or DST-adjusted zero-hour time value will be used instead.".
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
9 Jul 2009 5:30 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
I think the question is, should 2/2/2 actually match d/m/Y, d/m/y, n/j/Y or n/j/y in strict mode?
-
9 Jul 2009 5:32 AM #5
The way it works now is that it will attempt to parse them in order, of format then altFormats.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Jul 2009 5:36 AM #6
-
9 Jul 2009 5:47 AM #7
Sencha Docs / Ext 3.x - ( Docs | Examples )
Learning Center / Saki's Examples (for 2.x) / HOWTO - ( Report Bugs | Post Proper Code )
-
9 Jul 2009 9:25 AM #8
Allow me put forward a simple behavior:
When a date (or a string for that matter) is typed into a dateField, it's surely within EXTJS' responsibility to check its validity.
But what if one requires a dateField which will not alter the content which is typed into the dateField (under any condition)? Surely, if a person types in 2/2/2 or 1/1/1 under strict mode, why should it be converted to anything at all?
I'd imagine a configurable flag : reformat: false, otherwise this is obtrusive behavior. Correct me if I'm wrong, but for functionalities like these, the configurability should be atomic.
I don't mean to diminish the efforts that the development team has already put into making this release, I mean, the volume, depth and beadth of the library speaks for itself, but I just personally feel that this is something which is too basic to be missed.
Silly me would imagine something like this:
Code:var cl = new Ext.form.DateField({ allowBlank : true, applyTo: item, hideTrigger: (item.readOnly || item.disabled), minValue: (item.readOnly || item.disabled)?'01/01/0001':today, validationDelay: 40, maskRe: /\d|\//, reformat: false });
-
9 Jul 2009 3:58 PM #9
You're misunderstanding what the strict option does. Strict basically stops the rolling over of dates, which is the automatic behaviour of the javascript date objects. You're talking about something completely different. By default the date field is configured with a format and then a series of alternate formats, so when an input is entered it attempts to parse the value to get a date out of it. You could clear the altFormats to ensure that the date can only be inputted in the format you've specified.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
16 Aug 2009 12:30 PM #10
No response in some time, can this be updated to CLOSED?
MJ
API Search || Ext 3: docs-demo-upgrade guide || User Extension Repository
Frequently Asked Questions: FAQs
Tutorial: Grid (php/mysql/json) , Application Design and Structure || Extensions: MetaGrid, MessageWindow
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote