How to dynamically change mask?

Change an input mask dynamically in ChronoForms.

Overview

The jQuery .data() method does not update the mask attribute correctly.
Set the data-inputmask attribute directly and re-initialize the inputmask. Ensure a dummy mask is set in the form's Extra Attributes to load the required script.

Answered
ChronoForms v6
fl flashfs 12 Sep, 2017
Using 6.0.9 and I'd like to know if is there any possibility to change an input mask dinamycally, say from a JS code. I already tried to use something like jQuery("#id").data("inputmask", "99-99") but the form doesn't update itself.
fl flashfs 15 Sep, 2017
Answer
1 Likes
This was the only way I've found that worked:

jQuery("#id").attr("data-inputmask", " 'mask' : '999.999.999-99' ");
jQuery("#id").inputmask();

I don't know why .data() didn't work.
By the way, to inputmask() works, you have to write a dummy mask on Advanced > Extra attributes, so the script jquery.inputmask.bundle is loaded:

data-inputmask: 'mask' : ''
This topic is locked and no more replies can be posted.