I am using accounting.js (along with bindWithDelay.js) to format a number on keyup or blur. The issue is that when I input in the textbox the second time to modify the number, the plugin formats the number incorrectly the second time.
For example, if I enter the number 28,1
, accounting.js formats it this way 28,10
. This is the expected output. But when I modify the number the second time to 28.16
, accounting.js formats it again to 2.816,00
which is not the intended result.
This is the code:
JS:
accounting.settings = {
number: {
precision : 2, // default precision on numbers is 0
thousand: ".",
decimal : ","
}
}
$(".c").bindWithDelay("keyup", function() {
$(this).val(accounting.formatNumber($(this).val()));
}, 2000);
HTML:
<input class="c" type="text" id="height" name="height" value="" />