RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.4k stars 2.17k forks source link

removeMaskOnSubmit doesn't work for appended elements #2586

Open Aerellon opened 2 years ago

Aerellon commented 2 years ago

removeMaskOnSubmit doesn't work when applied on inputs which are appended by js/jquery. Tried to set removeMaskOnSubmit to true in different ways, but none worked so far.

Inputmask.extendDefaults({
    autoUnmask: true,
    removeMaskOnSubmit: true
});

$(document).on("click", ".add-tr", function () {
    var x = $("#details tr").length - 1;
    if (x < 40) {
        $("#details tbody").append('<tr><td><input type="text" name="details[' + x + '][tsz]" class="tsz" maxlength="11"></td><td><input type="text" name="details[' + x + '][ft]" class="ft" maxlength="7"></td><td><button type="button" class="add-tr" tabindex="-1">+</button></td><td><button type="button" class="remove-tr" tabindex="-1">x</button></td></tr>');
        $("#details tr:last .tsz").inputmask({
            mask: "9{3}-9{5}-9{1}",
            removeMaskOnSubmit: true
        });
    }
});

Browser: Chrome (97.0.4692.99) Version: 5.0.8-beta.2

augustoalvess commented 10 months ago

same problem here...