Skip to content

Instantly share code, notes, and snippets.

@desenvolvendositeswp
Created November 23, 2024 16:24
Show Gist options
  • Save desenvolvendositeswp/ad87d5f2b8acd8053ff7caccfa6513a5 to your computer and use it in GitHub Desktop.
Save desenvolvendositeswp/ad87d5f2b8acd8053ff7caccfa6513a5 to your computer and use it in GitHub Desktop.
Mascara CPF para jetformbuilder
<script>
document.addEventListener("DOMContentLoaded", function() {
var cpfField = document.querySelector('input[name="c_cpf"]'); // Altere para o nome correto do campo
if(cpfField) {
cpfField.addEventListener('input', function(e) {
var value = e.target.value.replace(/\D/g, '');
if (value.length <= 11) {
value = value.replace(/(\d{3})(\d{3})(\d{3})(\d{1})/, '$1.$2.$3-$4');
}
e.target.value = value;
});
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment