Created
November 23, 2024 16:24
-
-
Save desenvolvendositeswp/ad87d5f2b8acd8053ff7caccfa6513a5 to your computer and use it in GitHub Desktop.
Mascara CPF para jetformbuilder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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