Example var number = 3500; I want you to return 3,500
Example var number = 3500; I want you to return 3,500
Solution with JS Regex
function currencyFormat (num) {
return num.toFixed(2).replace(".", ",").replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")
}
Jose, you can use the jQuery MaskMoney plugin
The usage is basically this:
$("#id_input").maskMoney();