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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)