Remove leading zeros from input type=number

前端 未结 7 2076
一个人的身影
一个人的身影 2021-02-07 01:17

I noticed that if i use the leading zeros are not removed. I also saw a lot of discussion on how keeping leading ze

7条回答
  •  醉话见心
    2021-02-07 01:37

    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.

    In my case, myNumber stores a year number. This way, the year 2018 (for example) won't be displayed mistakenly as 02018.

提交回复
热议问题