inputmask

Initialize inputmask on dynamically duplicated form fields.

Overview

When duplicating form fields with jQuery, the inputmask functionality does not automatically apply to the new elements.
After duplicating the element, reinitialize the inputmask by targeting the new field's class selector.

Answered
Ga Gatsman 24 Oct, 2015
Hi,
I got a form that has among others 2 input fields that use a date inputmask dd/mm/yyyy
The form can be duplicated on click with jQuery but the inputmask does not work for the new created fields.

Is there anything i can add to the duplication code that can reload the inputmask everytime a new line is rendered?

- John
Gr GreyHead 24 Oct, 2015
Answer
Hi John,

I think that you have to initialise the mask on the new input when you duplicate the element. If you have the mask set as a data item then jQuery("#element_id").inputmask(); should be enough.

Bob
Ga Gatsman 24 Oct, 2015
Geat thank you Bob,
I changed it to .element_class since the element_id gets updated for every new row.

- John
This topic is locked and no more replies can be posted.