RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.4k stars 2.17k forks source link

Conflict with jQuery UI datepicker #550

Open ZiadJ opened 10 years ago

ZiadJ commented 10 years ago

In a v2.3.64 I've been successfully instanciating datepickers in KnockoutJs using this binding handler:

    // Usage: <input data-bind="datepicker: someDate" />
    ko.bindingHandlers.datepicker = {
        init: function (element, valueAccessor, allBindingsAccessor) {
            $(element).datepicker({ dateFormat: 'dd/mm/yy' })
                      .inputmask('dd/mm/yyyy');
        },
        update: function (element, valueAccessor) {
            var value = ko.utils.unwrapObservable(valueAccessor());
            var current = $(element).datepicker("getDate");
            if (value - current !== 0)
                $(element).datepicker("setDate", value);
        }
    };

However with v3.0.33 I'm getting two issues when some date is initially loaded in the input box:

  1. I need to type "/" after entering the first two date digits before I can proceed with entering the month else the selection stays stuck on the slash character.
  2. When I type 3 at the beginning of a date it automatically sets the date to 03 when I'm actually trying to type 30 or 31. It should wait for me to enter the second digit before applying any corrections.

After removing the jQuery UI datepicker those issues were gone but I've reverted to v2.3.64 instead and everything's working just fine again.

RobinHerbots commented 10 years ago

@ZiadJ ,

Can you retry by adding this option to the inputmask.

.inputmask('dd/mm/yyyy', { placeholder: "_" });

ZiadJ commented 10 years ago

Sorry but that did not help much. The same issues were still there after I added the option.

RobinHerbots commented 10 years ago

Ok, Can you make a jsfiddle with the options you are using for the datepicker and the options for the inputmask which shows the problem.

best regards,

Robin

2014-07-01 23:50 GMT+02:00 Ziad Jeeroburkhan notifications@github.com:

Sorry but that did not help much. The same issues are still there after I added the option.

— Reply to this email directly or view it on GitHub https://github.com/RobinHerbots/jquery.inputmask/issues/550#issuecomment-47714152 .

RobinHerbots commented 10 years ago

@ZiadJ ,

Can you have a look at http://jsfiddle.net/tju9L/1/ there is a datepicker with an inputmask.

ZiadJ commented 10 years ago

Here's the fiddle: http://jsfiddle.net/LD3XT/1/

Actually I got the proper behavior back after I commented the lines using setDate but then I can't think of any other way round.

RobinHerbots commented 10 years ago

It is propably me, but it seem to work.

2014-07-02 20:51 GMT+02:00 Ziad Jeeroburkhan notifications@github.com:

Here's the fiddle: http://jsfiddle.net/LD3XT/

Actually I got the proper behavior after I commented the lines using setDate on the datepicker but then I can't think of any other way round.

— Reply to this email directly or view it on GitHub https://github.com/RobinHerbots/jquery.inputmask/issues/550#issuecomment-47819227 .

ZiadJ commented 10 years ago

In my implementation only the first digit gets selected upon focus instead of the current full selection. This is to spare the user from having to type the month and year all over again. You can simulate this by selecting the first digit manually prior to typing the date. In this particular case I'm getting 12/01/2012 after typing 12/12/12 when it should be 12/12/2012 and I get blocked if I omit the slashes(tested on FF30 & IE11).

RobinHerbots commented 10 years ago

@ZiadJ ,

Yes I see, ... I will have a look at it.

RobinHerbots commented 10 years ago

@ZiadJ ,

It is the not so intelligent intelligence ;-)

04/07/2014 overtyping with 12/1 => converts to 12/01 because 17 is not a valid month.