Closed 4lessandrodev closed 3 years ago
Validate digits
Possible Province
Example CPF nº 000.000.006-00
0 - Rio Grande do Sul
1 - Distrito Federal, Goiás, Mato Grosso do Sul e Tocantins
2 - Pará, Amazonas, Acre, Amapá, Rondônia e Roraima
3 - Ceará, Maranhão e Piauí
4 - Pernambuco, Rio Grande do Norte, Paraíba e Alagoas
5 - Bahia e Sergipe
6 - Minas Gerais
7 - Rio de Janeiro e Espírito Santo
8 - São Paulo
9 - Paraná e Santa Catarina
Regex to validate CPF
/^([0-9]{3})[\.]((?!\1)[0-9]{3})[\.]([0-9]{3})[-]([0-9]{2})$|^[0-9]{11}$/
Remove special chars
cpf.replace(/[\.]|[-]/g,'');
CPF stands for Cadastro de Pessoas Físicas (Natural Persons Register). Native Brazilians can request a CPF at any time in their lives - parents will often apply on behalf of their children when they are newborns, as CPFs are vital to living in Brazil and it’s best to obtain one sooner rather than later.
A CPF is 11 digits long, comprised of nine base digits, and two digits at the end that are the result of an arithmetic operation on the first nine numbers, meaning any typing mistakes will lead to an invalid number. Here is an example of a CPF: 231.002.999-00.