I want to allow the user to enter the amount between 0 and 1000. Optionally he can enter the amount with cents. Examples of amounts I want to allow: 199.99, 29.90, 999.99, 0.01, 10, 999
I tried this, but it doesn't really work:
$('.input-price').mask('000.00', {reverse: true});
Is there any other, working way you can propose me?
You can use the 9
placeholder, which makes the digit optional:
$('.input-price').mask('099.99');
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.15/jquery.mask.js"></script>
<input type="text" class="input-price" placeholder="Enter price..." />