RobinHerbots / Inputmask

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

Date Mask default to current year #2410

Closed bayuprimajaya closed 1 year ago

bayuprimajaya commented 3 years ago

Hi Robin,

I just trying your library for masking date input, something like this :

Inputmask('datetime', {inputFormat: "dd/mm/yyyy", placeholder: "__/__/____", max: todayFormatted()}).mask('date');

todayFormatted() is my custom function returning current date in "dd/mm/yyyy" format.

It is actually work fine, but when I type 2 digits of year part which matches first 2 digits of current year, it defaults to current year. So, when I type 20, it is automatically give 2020 as the result.

Is it the desired behaviour? because it give me trouble. For example input for date 01/01/2007, when I type 01/01/20, it will automatically gives 01/01/2020. So I have to delete the last 2 digits and retype 07 part.

Thanks

RobinHerbots commented 3 years ago

@bayuprimajaya ,

The inputmask makes a suggestion but you can overtype the added 20 by typing the 07 part. You do not need to delete it.

Anyway someone has send in a PR #2396 , to add a flag to enable/disable the year prefill. I will add it soon.

DMScherer commented 3 years ago

An option flag to disable the preFilling like in the mentioned PR would be great!

georgedenning commented 1 year ago

Looks like PR #2396 was never merged. I've figured out that the ability to disable prefilling dates has been implemented with the option flag prefillYear as of #2395

RobinHerbots commented 1 year ago

True, but the option is included.

https://github.com/RobinHerbots/Inputmask/blob/5.x/README_date.md#prefillyear