Remove leading zeros from input type=number
I'm going to give an example with react usage. It uses state
which store the value of the field. But, I think u can replace it with whatever variable you like.
<input type='number' value={Number(this.state.myNumber).toString()}/>
In my case, myNumber
stores a year number. This way, the year 2018
(for example) won't be displayed mistakenly as 02018
.
just use a regular expression like this
textboxText= textboxText.replace(/^0+/, '')