document.addEventListener('DOMContentLoaded', function () { const cpfInputs = document.querySelectorAll('input[name="form_fields[cpf_cliente]"]'); cpfInputs.forEach(function (input) { input.addEventListener('input', function () { let value = input.value.replace(/\D/g, ''); // só números if (value.length > 11) value = value.slice(0, 11); value = value.replace(/(\d{3})(\d)/, '$1.$2'); value = value.replace(/(\d{3})(\d)/, '$1.$2'); value = value.replace(/(\d{3})(\d{1,2})$/, '$1-$2'); input.value = value; }); }); });