Remove leading zeros from input type=number

前端 未结 7 2154
一个人的身影
一个人的身影 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:46

    Html input tags always return text, not numbers, even its content can be coerced to numerical format, dates, etc...

    So next you should convert that input to actual number format:

    parseInt(myNum); // If you expect an integer.
    parseFloat(myNum); // If you expect floating point number.
    

提交回复
热议问题