HTML5 Input type=number removes leading zero

<input type="text" pattern="[0-9]*" ...

that should do it for you. Will bring up the numeric keypad on iPhone and the nicer Android phones I've tested on.


<input type="tel"> has been introduced for this exact purpose. It's one of the new input types in HTML5.


I needed it for mobiles browsers and I used a mix of both solutions like this :

<input type="tel" pattern="[0-9]*">

On iOS, the numeric keyboard appear with only numbers available (no # or * symbols) whereas on Android phones, the "tel" is correctly interpreted but not the pattern (not yet on the few phones I have).

I guess that when android browsers will start to implement "pattern" attribute, this should work fine on android too (as the whatwg spec suggests).

Until then you will have to check for non numeric characters in your input and remove them. javascript replace(/[^0-9*]/g,'') is useful for this.

hope this helps