Inputmask: Backspace alters value/mask in datetime

Created on 22 Jul 2019  路  9Comments  路  Source: RobinHerbots/Inputmask

I am using this library for date formatting. And I seem to have an issue with Backspace key. Whenever I use Backspace to remove one digit from the date, the actual date gets altered in a wrong way.

I see there was a similar question asked here, which has no answer.
https://github.com/RobinHerbots/Inputmask/issues/1793

Here is a JSFiddle: https://jsfiddle.net/06zkdqxn/1/

For this example, if I would type in the input 25/05/2019, then go after the digit '1' in the year and pressing Backspace, then the value would look like this: 25/05/209y, I would expect to be 25/05/20y9 because I didn't remove the last digit.
For the same date (25/05/2019), if I would go to the digit '5' in the month and press 'Backspace', then the value looks like this: 25/02/019y. Month is replaced with digit '2' and last digit of the year is replaced with 'y'. In this case, I would expect to look like this: 25/0m/2019

Thanks a lot!

Dates Enhancement / Feature

Most helpful comment

Hello,

I tried again using the latest fix and now everything works fine! I tested with multiple Date formats, also including hours/minutes. Looks good!
Not sure about the delete issue, I also tried that but seems to me it works fine.

Thank you for the fix! :)

All 9 comments

@Evelyne28 ,

I'm working on it.

Thank you!

@Evelyne28,

Can you have a try.
https://jsfiddle.net/dtvk9n7s/

I changed the behavior depending the insertmode.

Hello!

Thank you for the fix.
I tried again locally and whilst Backspace issue seems to work fine, seems there are 2 small issues that popped up.

I tried to setup JSFiddle for the new issues, but I cannot find a public URL with the latest inputmask version. I also tried setting directly the _dist/jquery.inputmask.js_ in the Resource tab, but that's not working.

Thanks, works now! Here is the JsFiddle:
https://jsfiddle.net/q4mh9fdc/

Steps to reproduce the 2 additional issues:

  1. Set a date in the input (e.g 26/05/2019)
  2. Focus out of the input
  3. Click on the '6' digit from the Day, in the input
  4. Press Backspace

In this case, it removes both digits from the Day (dd/05/2019). The same thing happens if you click on the first digit from the Day and then press Backspace.
Seems like it's an issue related to the first two characters (it also applies to other formats (e.g yyyy/mm/dd)

Other than that, looks good!

@Evelyne28 ,

The issue is fixed. If you find other issues please report them.

@Evelyne28,

Gr, know the delete behavior needs some review :-(

Hello,

I tried again using the latest fix and now everything works fine! I tested with multiple Date formats, also including hours/minutes. Looks good!
Not sure about the delete issue, I also tried that but seems to me it works fine.

Thank you for the fix! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

webmastervinay picture webmastervinay  路  4Comments

pikaclint picture pikaclint  路  3Comments

RobinHerbots picture RobinHerbots  路  4Comments

JosephWJMaxwell picture JosephWJMaxwell  路  7Comments

blaskognia picture blaskognia  路  5Comments