Last active
August 21, 2019 18:40
-
-
Save joseolinda/015b260bc4e388cd79adf2b09f785944 to your computer and use it in GitHub Desktop.
Mascarar CPF onBlur
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
const CPFInput = document.querySelector("#cpf"); | |
CPFInput.addEventListener("blur", () => { | |
let CPFFormatado = CPFInput.value.replace( /^([\d]{3})([\d]{3})([\d]{3})([\d]{2})$/, "$1.$2.$3-$4"); | |
CPFInput.value = CPFFormatado; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment