-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Issue description
When setting a value programmatically in an input field with an applied Inputmask, an issue occurs: if the cursor is placed before a "." or "-", the mask stops functioning correctly, and further input becomes impossible.
Steps to reproduce
- Include jQuery and the Inputmask library (version 5.0.2 or later).
- Add an input field to the page and apply the following mask:
99.99.99 - 99.99.99. - Programmatically set the value to
16.03.25 - 17.03.25(random). - Try placing the cursor before a "." or "-".
Expected Behavior
The cursor should be able to move freely within the input field without blocking data entry.
Actual behavior
When the cursor is placed before "." or "-", the mask freezes, and input becomes impossible.
Tested versions
- Version 4.0.9: Works correctly.
- Versions 5.0.0 - 5.0.1: The issue occurs only for "-".
- Version 5.0.2 and later: The issue occurs for both "." and "-".
Example code
<input type="text" data-date-target-pure class="history-filter__input">
<input type="text" data-date-target-jq class="history-filter__input">
<script>
let mask = Inputmask({
mask: "99.99.99 - 99.99.99",
placeholder: "dd.mm.yy - dd.mm.yy",
insertMode: false,
shiftPositions: false,
}).mask(document.querySelector('[data-date-target-pure]'));
mask.setValue('16.03.25 - 17.03.25');
$(function(){
$('[data-date-target-jq]').inputmask({
mask: "99.99.99 - 99.99.99",
placeholder: "dd.mm.yy - dd.mm.yy",
insertMode: false,
shiftPositions: false,
});
$('[data-date-target-jq]').val('16.03.25 - 17.03.25');
});
</script>Live example
This fiddle contains all tested versions from 4.0.9 to 5.0.10-beta.14 (just uncomment the desired version).
I suspect the issue might be related to the seekNext method used in keypressEvent, but understanding and fixing it is too complex for me.
Affected browsers
The issue occurs in all modern browsers, including Chrome and Firefox.
Metadata
Metadata
Assignees
Labels
No labels