Open erlingormar opened 11 years ago
I ran into the same problem, it's actually not a bug but this may be more clear in the doc :
// If a non-standard decimal separator was used (eg. a comma) unformat() will need it in order to work out // which part of the number is a decimal/float : accounting.unformat("€ 1.000.000,00", ","); // 1000000
So by having "," as a decimal separator, since unformat is called in formatNumber, you have to do something like this : result = accounting.formatNumber( accounting.unformat( input_value, ",") )
In using
accounting.js
, I noticed something strange when using a custom decimal separator (the European-style comma).The following code sample runs
accounting.formatNumber()
on two<input>
-fields to format their values (which works fine). Clicking a textbox will replace the value with theunformat()
-ed number (which works fine). However, when I change the value by typing a value such as64,00
(comma included) and callformatNumber()
, the result will have the decimal/thousand-separators placed in the wrong place (6.400,00
).The number is correctly formatted according to the preferences... only it's 100 times the original value ;)
I have set up an example here: http://jsfiddle.net/erlingormar/qp7mz/12/