I am using a Jquery mask plugin to format many things on my site and I am trying to figure out how to get it to format numbers in the way I need. I am using the following plugin.
https://igorescobar.github.io/jQuery-Mask-Plugin/
I am attempting to get the following format for my numbers.
999,999,999.99
The number is a currency field that needs a comma added every three digits and the value can be as low as 0.00
Well, this worked. I just tweaked the example from the website changing dots with commas and it worked.
$('.money').mask("#,##0.00", {reverse: true});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.13.4/jquery.mask.min.js"></script>
<input class="money" type="text"/>
As you can see there is no limitation of numbers. If you want to limit them, you can do $('.money').mask('000,000,000,000,000.00', {reverse: true});
Try this mask from their website with inverting commas and dots:
$('.money').mask('000.000.000.000.000,00', {reverse: true});
to have
$('.money').mask('000,000,000,000,000.00', {reverse: true});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With