USSliberty USSliberty - 1 year ago 287
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 Source

just use a regular expression like this

textboxText= textboxText.replace(/^0+/, '')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download