0

I am struggling to figure out the proper onChange handler that will allow me to format a number input with commas and also allow up to two decimal places.

Test Cases: input: '1234.56' -> output: '1,234.56' input 'aaaa1234567.34' -> output: '1,234,567.34'

I do not want this formatting to occur onBlur, I want the formatting to occur onChange so the commas are inserted as you type.

This is my first stack-overflow question so forgive me if my write up is not great.

I have searched for working examples on stack-overflow. The closest thing I found was this, but it does not work in Safari (I followed the comments but could not find a solution). I am not great at regex and have spent about 5 hours trying to figure this out.

0 Answers0