Buy Now
Sign in

Clear input mask on lost focus

Joao Serina , November 02 2017
Joao Serina

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.