Instantly format text input

As Giri already told you, you can do it by using RegEx, or you do it by using a Combination of →

.replace()
.substring()
.slice()
and all the other given STRING-methods.

If you want to see the change live, while typing in the value, then you will need it to place inside → onChange()

With every typing letter into your inputfield, the → onChange event will be fired up.