Format value in cash while typing with pure javascript

Asked

Viewed 16,554 times

13

There are several questions in the OS about coin formatting, but most of them do not format while a number is typed correctly. How can I format the numbers while typing, passing in these cases below?

For example (input > output):

1 > 0,01

12 > 0,12

123 > 1,23

1234 > 12,34

12345 > 1.234,50

123456 > 1.234,56

123456789 > 1.234.567,89

  • You can use this regex like the user Asura Khan did and put a function. onChange on its label: https://answall.com/questions/181922/formatar-moeda-brasileira-em-javascript/181924#181924? newreg=06f97779a36346cda7edb6c52c1e7699

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.