Forums

Clear input mask on lost focus

Joao Serina 02 Nov, 2017
Hello,

I have placed a mask on my input text field trough the extra attributes field. Now I would like for the mask to be removed once the input looses focus or in some cases when the data is submitted.

According to the InputMask github page there is a function called "clearMaskOnLostFocus" and one called "removeMaskOnSubmit". I would like to combine these with my input mask but I have not been successful.

Here is what I have tried:
data-inputmask:'mask': '99999999 9 **9', data-inputmask:'clearMaskOnLostFocus': 'true'

This has no effect and even disables my mask. Changing the coma (",") for a semi-colon (";") has the same effect

data-inputmask:'mask': '99999999 9 **9'
data-inputmask:'clearMaskOnLostFocus': 'true'

Also has no effect and even disables my mask.

data-inputmask:'mask': '99999999 9 **9'
clearMaskOnLostFocus = 'true'

The mask works but "clearMaskOnLostFocus" doesn't. The result is the same if I change the equals sign ("=") with a colon (":").

Thank you for your time.
chekwan 24 Sep, 2018
I also have the same problem.

can someone give the solution.?
healyhatman 24 Sep, 2018
In a custom JS block, with the "DOM-ready" checkbox ticked, you could add a .blur() function to the field so that when it blurs (loses focus) it runs your function. Don't know about the submission one, but you should probably just leave it all and strip them out in PHP later anyway.
This topic is locked and no more replies can be posted.