Skip to main content

Search and Top Navigation

#5793 closed bug (notabug)

Opened July 03, 2010 11:57PM UTC

Closed October 11, 2012 06:57PM UTC

Last modified October 11, 2012 09:15PM UTC

Datepicker + Masked Input

Reported by: marcos.pont Owned by:
Priority: minor Milestone:
Component: ui.datepicker Version: 1.8.2
Keywords: parseDate, updateDatePicker, masked input Cc:
Blocked by: Blocking:
Description

When using Datepicker with Masked Input plugin, the input value is cleared out when the user types a date value.

This happens because JUI Datepicker considers dates with 2 digit year as valid dates inside the parseDate method.

So, if a valid date is found (for instance, 07/04/10), the _updateDatePicker method is called and then the native focus() function is called on the input.

This calls the focus handler on Masked Input plugin. If the mask defined for the field expects year with 4 digits, the 2 digit year will make the date invalid and the input will be cleared out.

My suggestion is: is it possible for Datepicker to accept years with 2 digits based on a configuration setting? This would help developers using Datepicker and Masked Input to make them work together.

I have tried to think of a solution that would change Masked Input's code, but I couldn't. Since the entered value is not a full date, it does not respect the defined mask and there's no workaround for this.

Thanks in advance!

Attachments (0)
Change History (4)

Changed July 04, 2010 12:20AM UTC by marcos.pont comment:1

I have made more research on how to find a fix for this issue.

In order to make Datepicker work with Masked Input plugin, we would need 2 things:

  • allow the user to configure datepicker to ignore partial date parts (day with digits != 2, month with digits != 2, year with digits != 4). This could affect the regular expression used inside the getNumber private function inside the parseDate method.
  • don't call the focus() method of the input inside _updateDatepicker when the input already has focus. This could be achived if _updateDatepicker could know if it's being called from inside an event handler that was triggered on the datepicker input field. The focus() function should still be called if the user types a date and the focus is not on the input field

Changed September 16, 2010 04:56PM UTC by daniel comment:2

Hi,

After having same problem (Datepicker + Masked Input), I just removed the call to focus() at the end of _updateDatepicker() and I'm very happy with this new behavior.

For me, leaving updateDatepicker() without calling focus() at all is quite acceptable.

Changed October 11, 2012 06:57PM UTC by scottgonzalez comment:3

resolution: → invalid
status: newclosed

The datepicker supports specifying a date format. This is definitely not a bug in datepicker.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:4

milestone: TBD

Milestone TBD deleted