Use pattern="[0-9]*"
-
Example number input:
<input type="number" pattern="[0-9]*" />
-
Example phone input:
<input type="tel" pattern="[0-9]*" />
Note: Browsers that do not support type="tel"
will default to a text type
Beware: Using type="number"
can cause problems with some browsers and user experience for credit card, postal code, and telephone inputs where a user might need to enter punctuation or a comma being in the output.
References:
- http://bradfrost.com/blog/mobile/better-numerical-inputs-for-mobile-forms/
- http://danielfriesen.name/blog/2013/09/19/input-type-number-and-ios-numeric-keypad/