Created
July 22, 2017 11:17
-
-
Save profburnes/71fafc0d5798100eec2c9eaf4e33583c to your computer and use it in GitHub Desktop.
Formatar Valores com JS
This file contains 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
//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