Login Register

DateTextBox Validation

Hi, I'm brand new to Dojo, and I'm attempting to use the DateTextBox widget to give users a localized calendar from which to select a date. The localization aspect is working well, so that part is great.

My problem is that I need to be able to send the localized displayed value to the server rather than the universal Dijit value. I've been able to accomplish that with a dynamic serialization formula. However, for complicated reasons, I also need to be able to validate the displayed value rather than the Dijit value using an existing script. How can I do that?

Ideally, I'd like to be able to "turn off" the Dijit validation completely and use an onchange event to check the current displayed value from the text box. I just can't seem to figure out how to make that work. By default, the onchange event for the widget doesn't seem to be triggered when an invalid value is entered (even though the hidden Dijit value does change to "undefined"). How can I disable Dojo's built-in validation on this widget and use ordinary JavaScript validation in its place?

Thanks in advance for any help.

Denise

you could try overriding the

you could try overriding the 'serialize' method to simply point at the 'format' method to send the value as-is to the server (that is the simplest solution I can think of; in fact, that wastes a lot of cycles, but the widget was designed specifically to avoid this)

I'm not sure what you mean by custom validation -- if you're using the localization functionality, you're pretty much locked into the localized date formats. Anything else would require by-passing the date format localization entirely, I think. If you aren't using the validation or the ISO date functionality, it might make sense for you to just write your own widget based on ValidationTextBox and steal the _Calendar popup code.

Clarification of DateTextBox validation issue

Thanks, peller.

Just to clarify, the values I need to send to the server are the short-form date strings for each locale (e.g., "14.05.2008" for Germany, "2008-5-14" for China, etc.). I was able to get that working by dynamically generating the date pattern in my serialize function to match each locale. That is working fine and doesn't seem to be a problem.

We do want to use the localization functionality, because we need the calendar popup to display differently for each locale (e.g, language translation of the month and day names, different week start days, etc.).

Our only problem is that we need to validate the displayed value of the widget rather than the hidden, server-bound value. I understand that Dojo's validation will be looking at the server-bound value, but I'd like to turn that off (is there an easy way to do that?) and substitute my own event-triggered validation (e.g., with onchange) to check the displayed value instead. Does that make sense? Is it possible? It seems like it should be, but I'm having lots of trouble getting it to work.

Thanks,
Denise