Wrong masked values without decimal
See original GitHub issueHey guys… When I’m editing some fields and I have my input rendered as follow:
<input type="text" class="mask-money" value="10000" data-thousands="." data-decimal="," data-prefix="R$ ">
<input type="text" class="mask-money" value="4500" data-thousands="." data-decimal="," data-prefix="R$ ">
<input type="text" class="mask-money" value="1" data-thousands="." data-decimal="," data-prefix="R$ ">
<input type="text" class="mask-money" value="1.1" data-thousands="." data-decimal="," data-prefix="R$ ">
<input type="text" class="mask-money" value="0.8" data-thousands="." data-decimal="," data-prefix="R$ ">
<input type="text" class="mask-money" value="0.88" data-thousands="." data-decimal="," data-prefix="R$ ">
First, feels weird to have to do this in order to mask the fields:
$('.mask-money').maskMoney(); // shouldn't this be enough?
$('.mask-money').maskMoney('mask'); // is this really necessary?
But the problem is that I get this values:
- 100,00 (instead of 10.000,00)
- 45,00 (instead of 4.500,00)
- 0,01 (instead of 1,00)
- 0,11 (instead of 1,10)
- 0,08 (instead of 0,80)
- 0,88 (yeah! fot his one right)
Issue Analytics
- State:
- Created 9 years ago
- Comments:17 (3 by maintainers)
Top Results From Across the Web
[Input Masks Library] Incorrect value when decimal has no ...
Hello. When using the currency mask on an edit screen, if the value got from the fetched data is for instance 123.45, it...
Read more >Input mask for numeric and decimal - javascript - Stack Overflow
but when he put 555555 it's error, so I need to specify the mask where the mantissa is optional 0 to 999 and...
Read more >Custom Input Masks (Numeric/Integer) - Informa Software
Numeric input masks are specifically designed for entering numeric values ... Decimal. The mask for entering integer values of a fixed and flexible...
Read more >ngx-mask - npm
You can choose if mask will allow the use of negative numbers. The default value is false . Usage. <input type="text" ...
Read more >Control data entry formats with input masks - Microsoft Support
If someone enters a phone number without the area code, Access won't write the ... For example, this is an input mask for...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We ran into this issue as well. As a work around I am using javascripts Number() to convert the value to a number during the mask. Below is an example:
http://jsfiddle.net/5pgdq8od/1/
see pull request with possible fix: https://github.com/plentz/jquery-maskmoney/commit/2de7b9a5f09d44731fcd0ef9c0c751eeb24e48b1
jsfiddle with some tests for fix: http://jsfiddle.net/6vyL2v7f/
I’ve read everything but I had to solve my problem RIGHT NOW. So here goes an UGLY patch. My values that should show R$ 500,00 were showing as R$ 50,00.
It makes the value of the field get two decimals when it has only one, so 500.0 becomes 500.00, 100.1 becomes 100.10. I do it right before setting the maskMoney on the field, and it fixed it for now (for me)
Be very careful with this patch. I will remove it as soon as the rails gem I’m using for this lib is correct.
I hope that helps someone somehow, and here goes my +1 for fixing this.