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 6 years ago
- Reactions: 6
- Comments: 19 (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
The problem still exists. I have the same problem with the date pattern right now.
Just got the same issue in
react-native-imask
but with patternmm/dd/yyyy
. Managed to fix it viadate-fns
:Hope it will help someone!
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
pattern
for date mask I also need to specifyformat
andparse
functions 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
pattern
withoutformat
andparse
functions and throw an error if it’s been passed?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”