Skip to content

Instantly share code, notes, and snippets.

@profburnes
Created July 22, 2017 11:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save profburnes/71fafc0d5798100eec2c9eaf4e33583c to your computer and use it in GitHub Desktop.
Save profburnes/71fafc0d5798100eec2c9eaf4e33583c to your computer and use it in GitHub Desktop.
Formatar Valores com JS
//forma simples de formatar valores
function formatar(valor) {
valor = valor.replace(".","");
return parseFloat(valor.replace(",","."));
}
function formatarReal(valor) {
valor = valor.toFixed(2).split('.');
valor[0] = valor[0].split(/(?=(?:...)*$)/).join('.');
return valor.join(',');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment