Opened 9 years ago

Closed 7 years ago

Last modified 7 years ago

#5793 closed bug (notabug)

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!

Change History (4)

comment:1 Changed 9 years ago by marcos.pont

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

comment:2 Changed 9 years ago by daniel

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.

comment:3 Changed 7 years ago by Scott González

Resolution: invalid
Status: newclosed

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

comment:4 Changed 7 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.