igorescobar / jQuery-Mask-Plugin

A jQuery Plugin to make masks on form fields and HTML elements.
http://igorescobar.github.io/jQuery-Mask-Plugin/
Other
4.77k stars 1.42k forks source link

Cant get the money mask to work #762

Open whitsey opened 3 years ago

whitsey commented 3 years ago

I am getting irregular results and I am not sure if it is me or the plugin

I have a value: 2520000

I apply a mask: $('.amount_total').mask('$##,###,###'); and: $('.amount_total').mask('$##,###,###.##');

Result: $25,200,00

I also tried: $('.amount_total').mask('$#,###'); and: $('.amount_total').mask('$#,###.##');

Result: $2,5200,00 and: $2,520.000

I also tried: $('.amount_total').mask('$000,000,000'); and: $('.amount_total').mask('$000,000,000.00');

Result: $252,000,0

What am I doing wrong?

CAVAh commented 3 years ago

The problem is you should use {reverse: true} option. And using $ get some problems or anothers issues.

If you want a float number you should use this mask: $('.amount_total').mask("#.##0,00", {reverse: true});

ftcastro commented 1 year ago

Hello! I have a similar problem.

Tried to use both masks:

$('.mask-value').mask("#.##0,00", {reverse: true});
$('.mask-value').mask('000.000.000.000.000,00', {reverse: true});

to make my currency field work. But when I type the values, if it's a value like 10.000,00 ir generates only 1,00000000.

And if it's a value with several numbers, like 19.952,25 it shows only 199,52. And if I keep typing, it resets the value. Also, it does not accept the character "0".

Best regards, Fernando.