jQuery format currency forcing 2 decimals

623 Views Asked by At

It's a common pattern when entering a currency on touch devices to start entering the numbers, starting with the hundredths and forcing two decimal places, for example:

  1. User types 1, input formats it as .01
  2. User then types 2, input formats it as .12
  3. User then types 3, input formats it as 1.23
  4. User then types 4, input formats it as 12.34
  5. User then types 5, input formats it as 123.45

...and so on. It would also be nice if it would insert commas when the number is < 999.99 (i.e. 1,000.00).

I'm not sure what this pattern is even referred to as, so I haven't had much luck finding this functionality amongst the many already existing number formatting scripts.

0

There are 0 best solutions below