I have a UI where the user enters a number into a text box, which adds commas after every three digits after the decimal point. (For example: 1000 would become 1,000 and so on…)
Initially when the user enters a number 1,200. The value inside the box is treated as 1 instead of 1200. But when I reenter 1200 inside the same box. The number becomes the correct value of 1200.
How can I fix this so that the value will be 1200 no matter what.
When you’re retrieving the value initially, use JavaScript’s replace function remove all commas. For example,