Inputmask: Manual input via virtual keyboard doesn't work

Created on 21 May 2019  路  5Comments  路  Source: RobinHerbots/Inputmask

Hihi,
I do not exactly know if this issue has been already revealed or not. So so.. let's imagine that we have a web page with a virtual keyboard and an input section with Inputmaskjs (version 3.x.x). Every click on a button makes something like:

$input.inputmask("setvalue", $input.inputmask("unmaskedvalue") + char);,

where char equals text in a button (one symbol).

What if we initilize an inputmask with such parameters:

$input.inputmask({ regex: '7\\d{3}', showMaskOnHover: false, showMaskOnFocus: false });

What will happen? When we mash a button "7", it doesn't add 7, but if we do such thing with our real keyboard it adds "7". If we press any other button on our virtual web keyboard, for example "1", it adds this number and after this we can press "7" and it adds too.

Ok? Ok. But what if we initilize an input mask with additional parameter:

'autoUnmask' : true

and change a method of changing the intput:

$input.inputmask("setvalue", $input.val() + char);

It works with the button "7". It is a bit strange, I believe, because autoUnmask only changes val() to return an unmaskedValue instead of all symbols in the input.

Here you can check a live example!

WHY 3.x.x? we use an old version due to impossibility to clumsily fix this bug in newer versions using spaces in regex. I guess, there is a .trim() or something in passing a regex.
Basically, if we add a space before a regex it works.

Desktop:

  • Win10, WinXP, Win7;
  • Chromium (QT WebEngine), Chrome;
  • Version of inputmaskjs 3.x.x
  • Version of JQuery 2.1.0, 3.3.1.

Help, if you can, and thank you.

All 5 comments

@RipDevil ,

Ok, I had to read the issue twice and need to look at the example multiple times but , I understand the problem know.

I will have a look at the problem

@RipDevil ,

Have a look at the first field.

http://jsfiddle.net/tLcfuv97/3/

@RobinHerbots
Thank you, it really helped.

But what if we change our regex to:

regex: '\\d{3}7\\d{3}' or regex: '\\d{3}7'

It works strange too

Example: http://jsfiddle.net/ok2gey35/

@RipDevil,

It just shows the mask. So it is correctly, but I understand what you mean.
Adjusting the regex a bit gives the desired result. The seven is seen as a static entry in the mask. Adding the [] makes it an expression which is shown as _

    $("#first").inputmask({
                regex: '\\d{3}[7]' // or '\\d{3}7d{3}'
        });

@RobinHerbots
Thank you. It helped. I am closing this issue and wishing you more health and time.

_Message for other people: If the live examples don't work and you, my friend, who stumbeled upon the same issues, want to see the examples or if you work at a look-alike project and want to ask something, just write to me._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

webmastervinay picture webmastervinay  路  4Comments

osaris picture osaris  路  6Comments

blaskognia picture blaskognia  路  5Comments

hrolick-git picture hrolick-git  路  5Comments

RobinHerbots picture RobinHerbots  路  4Comments