This file contains 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
function maskCPF(element = new HTMLInputElement()) { | |
let cpfAtualizado; | |
const inputCpf = element; | |
const cpfAtual = element.value; | |
cpfAtualizado = cpfAtual.replace( | |
/(\d{3})(\d{3})(\d{3})(\d{2})/, | |
(_regex, one, two, three, four) => `${one}.${two}.${three}-${four}`, | |
); | |
inputCpf.value = cpfAtualizado; | |
return; |