function formatRp(number) { var number_string = parseInt(number).toString(), split = number_string.split(","), remainder = split[0].length % 3, amount = split[0].substr(0, remainder), thousand = split[0].substr(remainder).match(/\d{3}/gi); if (thousand) { separator = remainder ? "." : ""; amount += separator + thousand.join("."); } amount = split[1] != undefined ? amount + "," + split[1] : amount; return "Rp" + amount; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter