0

i want an < input> with decimals.

When a user entering for example 10 it should shows up 0.10 instead of 10 or 10.00.

Is this possible with HTML or do i need Angular/Javascript for this?

I also tried input type="numbers".. but this is same problem. This also add a comma, instead a point.

  • 1
    Possible duplicate of [HTML5 Number Input - Always show 2 decimal places](http://stackoverflow.com/questions/22641074/html5-number-input-always-show-2-decimal-places) – Hodrobond Jan 25 '17 at 18:26
  • https://stackoverflow.com/questions/17891714/how-to-create-a-dollar-amount-input-field-in-an-html-form – Josh Lee Jan 25 '17 at 18:49

2 Answers2

0

Try <input type="number" step="0.01" />

Neha Parab
  • 76
  • 7
  • this is not working. user input for example 22 is then 22. Not 0.22. –  Jan 26 '17 at 07:14
0

I found a solution with the jQuery Libary Mask (https://stackoverflow.com/a/30991945/6331266).

<script src="/your/path/to/jquery-mask.js"></script>
<script>
$(document).ready(function () {
    $('.usd_input').mask('00000.00', { reverse: true });
});
</script>

<input type="text" autocomplete="off" class="usd_input" name="dollar_amt">

https://jsfiddle.net/vcte6b0g/

Community
  • 1
  • 1