ngx-mask
ngx-mask copied to clipboard
Is it possible to keep characters in their positions when removing other characters?
Reproduction of my problem:
- I fill in a field which has a mask on it, let's say 0000-M0-d0 (for a date), and I realise I've entered an incorrect year.
- I press left arrow on my keyboard or select the cursor position with the mouse and remove the last digit in the year.
- Observe that the digits in the month and the day shift to the left, such that the first digit of the month becomes the last digit (which I just deleted) of the year, the next digit in the month becomes the first digit, the first digit in the day becomes the last digit in the month and so on.
If I am using context-based validation such as in a date, and not just digits, you can see that this causes problems with the validator.
My question is; is there a way to tell the plugin the keep the positions of the characters, such that they are replaced with the placeholder character when deleted, instead of shifting the entire input?
Something like this maybe? https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#keepcharpositions
Waiting for this fix too.
Not sure why this functionality was not included in version 12.0.0.
@alandeg @larini @tugando Thanks for using Ngx-mask. Please update to latest version. We added new feature keepCharacterPosition it example - https://stackblitz.com/edit/angular-b1dibw?file=src%2Fmain.ts