0
good morning!
What would be the way plus simple to display monetary values with Javascript? I was able to limit the decimals using .toFixed(2). Only the whole part goes something like this 10510.20 I wish it were 10.520,20. Any suggestions?
0
good morning!
What would be the way plus simple to display monetary values with Javascript? I was able to limit the decimals using .toFixed(2). Only the whole part goes something like this 10510.20 I wish it were 10.520,20. Any suggestions?
1
Use this function always gave me a huge fix for this problem:
function format_num(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
It would not be x.toString(). replace(/ B(?= ( d{3})+(?! d)/g, "." ); Point instead of comma in g, ",") . If possible put a run in your answer to test
not because the author wanted in commas
No, he says "I wanted it to be 10,520.20" point mile separator and decimal comma
Browser other questions tagged javascript html html5
You are not signed in. Login or sign up in order to post.
Take a look at this function: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
– rLinhares
But this desired result would be the return of?
– user60252