P粉0806439752023-08-24 20:31:11
accounting.js is a good choice. I'm using it on a project and had a very good experience using it.
accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99 accounting.unformat("€ 1.000.000,00", ","); // 1000000
You can find it on GitHub.
P粉2084690502023-08-24 14:10:15
Remove all non-decimal points/digits:
var currency = "-,400.50"; var number = Number(currency.replace(/[^0-9.-]+/g,""));