Buy Now
Sign in

Clear input mask on lost focus

Joao Serina , November 02 2017
J
Joao Serina
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.
C
chekwan
I also have the same problem.
can someone give the solution.?
healyhatman
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.
Web developer at SkySpider.com.au
I don't work for ChronoEngine but I do accept donations paypal.me/healyhatman