Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong masking when setting decimal value and decimal set to comma #247

Open
Joel-Mercier opened this issue Mar 19, 2018 · 3 comments
Open

Comments

@Joel-Mercier
Copy link

As I was trying to get a french formatting (decimals separated by a comma rather than a point) on my input mask, I noticed that when setting maskMoney('mask', 12.34) for example, the inserted value is transformed to 1234.00 (1234,00 € in the input field)
Here is a Fiddle : http://jsfiddle.net/2kfzyb0b/42/
From what I understand this has been fixed for english formatting but not for other values of the decimal option

@brunogc
Copy link

brunogc commented Jul 17, 2018

I'm experiencing the same problem!
The solution I found was to downgrade to version 3.0.0, where this issue does not occur.

@ericariyanto
Copy link

I Solved this issue with this scripts :
if ( $('.maskmoney').length ) { $(".maskmoney").maskMoney({ thousands: '.', decimal: ',', allowZero: true, prefix: 'Rp. ', affixesStay: true, allowNegative: false, precision: 2 }); $.each($(".maskmoney"), function(index, val) { $(this).val($(this).val() * 100).maskMoney('mask'); }); }

@gabuchoripper
Copy link

gabuchoripper commented Nov 16, 2022

i noticed that setting as string, but on correct format its working for me, so i was converting value into that and setting as normal val function, just remember to start input mask before

i've found this fix:
let money = 15.99; let formated_money = parseFloat(money ).toLocaleString('pt-br',{style: 'currency', currency: 'BRL'}); $('#input_money').val( formated_money );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants