javascripthtmlvalidationinputnumbers

Remove leading zeros from input type=number


I noticed that if i use <input type="number" /> the leading zeros are not removed. I also saw a lot of discussion on how keeping leading zeros.

For example "000023" and "23" are the same number and i think that it doesn't make sense keeping those zeros.


Solution

  • just use a regular expression like this

    textboxText= textboxText.replace(/^0+/, '')