Commit Inicial.
This commit is contained in:
parent
337d192710
commit
5d307207d9
3 changed files with 44 additions and 22 deletions
17
src/lhmask.js
Normal file
17
src/lhmask.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
module.exports = {
|
||||
// Entrada: 12345000 Saída: 12.345-000
|
||||
formatarCep(txt) {
|
||||
const soNumeros = e.target.value.replace(/[^\d]/g, '')
|
||||
if (!soNumeros) onChange(soNumeros);
|
||||
|
||||
let cep = '';
|
||||
cep += soNumeros.slice(0, 2);
|
||||
if (soNumeros.length > 2)
|
||||
cep += '.' + soNumeros.slice(2, 5);
|
||||
|
||||
if (soNumeros.length > 5)
|
||||
cep += '-' + soNumeros.slice(5, 8);
|
||||
|
||||
return cep;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue