USSliberty USSliberty - 6 months ago 65
Javascript Question

Remove leading zeros from input type=number

I noticed that if i use 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.

Answer

just use a regular expression like this

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