imaskjs: Bug with a custom pattern on Date mask
The user can’t type the last number when I change the pattern to d/m/Y.
new IMask(element, { mask: Date, pattern: 'd/m/Y' })
Browser: Safari 11 Demo: https://jsfiddle.net/p2Lt5j3b/1/

About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 7
- Comments: 20 (6 by maintainers)
@TonyE73 Check it works https://jsfiddle.net/o9gaydq8/
@uNmAnNeR this solution is a hack and does not work like the other behaviour - please reopen and say this is a temporary workaround
Just got the same issue in
react-native-imaskbut with patternmm/dd/yyyy. Managed to fix it viadate-fns:Hope it will help someone!
The problem still exists. I have the same problem with the date pattern right now.
Why is this issue closed if the problem is not fixed?
I solved it by changing the imask-6.4.3.js file, starting from line 2766 to 2784.
New code:
@ezze good idea about types, will check
lets make it red ? 😃
I faced the similar issue and found this thread. If I got it right, the problem is that if I provide any custom
patternfor date mask I also need to specifyformatandparsefunctions corresponding to it otherwise results will be unexpected like mentioned above.@uNmAnNeR Maybe, docs should be a little bit more specific on this. Wouldn’t it better to add typings constraints disallowing to pass non-default
patternwithoutformatandparsefunctions and throw an error if it’s been passed?Hi,
This setting using luxon works for me.
It seems that the problem of last digit when an error occurs during the format or parse function.
Hi, I am having the same problem despite adding parse and format returns ‘2018-10-2’ in input. Always leaves the last digit off. Other than this I am very impressed with the program
mask: Date, parse: function (str) {var yearMonthDay = str.split(‘-’); return new Date(yearMonthDay[0], yearMonthDay[1] - 1, yearMonthDay[2]); }, pattern: “Y-m-d”, dateFormat:“Y-
m-d”