Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing last two Zeros [AutoNumeric.js, JQuery]

I'm using autonumeric.js to generate currency number format, the problem is autonumeric's generating 2 more zeros after comma. e.g 40560000 became 40.560.000,00

I want to remove the last 2 zeros, so instead of 40.560.000,00 the result of autonumeric will be 40.560.000

This is my script :

$('td.sub_total').autoNumeric('init', {aSep: '.', aDec: ','});
$('td.vat').autoNumeric('init', {aSep: '.', aDec: ','});
$('td.total').autoNumeric('init', {aSep: '.', aDec: ','});

Any help will be much appreciated, thank you.

like image 897
M Ansyori Avatar asked Jul 28 '16 13:07

M Ansyori


1 Answers

According to the documentation, you can simply use the mDec key in the object.

Example:

$('td.sub_total').autoNumeric('init', {aSep: '.', aDec: ',', mDec: '0'});
$('td.vat').autoNumeric('init', {aSep: '.', aDec: ',', mDec: '0'});
$('td.total').autoNumeric('init', {aSep: '.', aDec: ',', mDec: '0'});
like image 63
TrampolineTales Avatar answered Sep 30 '22 09:09

TrampolineTales