jQuery-Mask-Plugin icon indicating copy to clipboard operation
jQuery-Mask-Plugin copied to clipboard

Cant get the money mask to work

Open whitsey opened this issue 5 years ago • 2 comments

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?

whitsey avatar Dec 14 '20 03:12 whitsey

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});

CAVAh avatar Jan 06 '21 12:01 CAVAh

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.

ftcastro avatar Jun 21 '23 14:06 ftcastro