Login Register

DateTextBox Input Date not in expected format

Hi

I want to use the DateTextBox widget but instead of the standard date format yyyy.MM.dd my INPUT date is in dd-MMM-yyyy (e.g. 05-Apr-2008). Somehow this input date format in not recognized and therefore the value of the respective input item is cleared. The user can normally use the widget but the old date is no longer visible. I tried to translate the input date into the format expected by the widget but it seems what dojo is always faster. Before I'm able to get control via JavaScript (e.g. OnLoad event) the value is already cleared and neither via "window.document.forms[0]" nor "dijit.byId("xxitem") I'm able to get the original date.

Any hint how to bypass this problem?

Thanks a lot for your help.

rene

Output date is fine but not INPUT date

Thanks for the link but the problem is only with the input date. I use the following code:

dojo.declare("newDateTextBox",[dijit.form.DateTextBox],
{
serialize: function(d, options)
{
return dojo.date.locale.format(d, {selector:'date', datePattern:'dd-MMM-yyyy'}).toLowerCase();
}
});

name="dtmDojo" value="16-Apr-2008" id="dtmDojo" dojotype="newDateTextBox" type="text" connstraints={datePattern:'dd-MMM-yyyy',selector:'date'}

Using this code I get the selected date in the right output format and I'm able to store it as required. The problem is to change the date. If I retrieve a document already containing a date (like in the example above - 16-Apr-2008) the existing date is not displayed by Dojo. It seems that the format can not be correctly parsed and therefore it is ignored. If I do not enter a date and save the document no date will be saved at all.

The question is how to have this date format correctly parsed by Dojo so that it can be displayed?

Thanks for a suggestion.

the parser accepts only ISO format

I don't recall if there are any easy ways to override this, but I think it was a design decision to keep this fixed. Other options I could think of are using programmatic declaration, turning off djConfig.parseOnLoad and doing fixups prior to triggering the parser yourself, or subclassing the widget to use an attribute other than value for your input, which would be defined as a String rather than a Date, then you can parse it as you like and set the value on the widget. None of these are graceful, I know.