This article mainly introduces the JS amount format conversion realization, the need for friends can refer to the
See the example directly: The code is as follows: function Fmoney (s, N)//s: Float number passed in, N: Want to return a few decimal points {n = n > 0 && n <= n:2; s = parsefloat ((s + ""). Replace (/[^d.-]/g, "")). ToFixed (n) + ""; var L = s.split (".") [0].split (""). Reverse (), R = S.split (".") [1]; t = ""; for (i = 0; i < l.length i + +) {T + = L[i] + ((i + 1)% 3 = 0 && (i + 1)!= l.length? "," : ""); Return T.split (""). Reverse (). Join ("") + "." + R; The function is called: Fmoney ("12345.675910", 3), returns the 12,345.676 code as follows: function Rmoney (s) {return parsefloat S.replace (/[^d .-]/g, "")); Returns the number in the format of the amount returned above to the float type. The code is as follows: Rmoney (12,345.676)//Return result is: 12345.676