How to convert a currency string to a double with jQuery or Javascript?

后端 未结 19 2730
天涯浪人
天涯浪人 2020-11-22 17:30

I have a text box that will have a currency string in it that I then need to convert that string to a double to perform some operations on it.

\"$1,1

19条回答
  •  借酒劲吻你
    2020-11-22 17:45

    accounting.js is the way to go. I used it at a project and had very good experience using it.

    accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99
    accounting.unformat("€ 1.000.000,00", ","); // 1000000
    

    You can find it at GitHub

提交回复
热议问题