what input field type forces the number pad mobile keyboard to come up when focused?

Ayyash picture Ayyash · Jul 30, 2010 · Viewed 68.5k times · Source

I tried the <input type="number" /> but on Opera that outputs a strange input box coupled with an "up and down" handler. What I expected was a regular text field that once you focus on it prompts the number keyboard instead of the alphabets. Is that even possible?

p.s. I'm not trying to validate. It would be a nice user experience, that's all.

Answer

Huski picture Huski · Nov 18, 2014

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: