forked from RiseUP/riseup-squad23
23 lines
541 B
JavaScript
23 lines
541 B
JavaScript
|
|
const FormatPeso = (valor) => {
|
|
if (valor == null) return 0;
|
|
const str = String(valor).replace(',', '.');
|
|
|
|
const clean = str.replace(/[^0-9.]/g, '');
|
|
console.log(parseFloat(clean))
|
|
return parseFloat(clean);
|
|
}
|
|
|
|
|
|
|
|
const FormatTelefones = (valor) => {
|
|
const digits = String(valor).replace(/\D/g, '').slice(0, 11);
|
|
return digits
|
|
.replace(/(\d)/, '($1')
|
|
.replace(/(\d{2})(\d)/, '$1) $2' )
|
|
.replace(/(\d)(\d{4})/, '$1 $2')
|
|
.replace(/(\d{4})(\d{4})/, '$1-$2')
|
|
}
|
|
|
|
|
|
export {FormatTelefones, FormatPeso} |