Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<input type="number"/> is not showing a number keypad on iOS

Tags:

html

ios

According to Apple's documentation when I setup an input element with a type of number I should get a number keypad.

<input type="number"/> 

number: A text field for specifying a number. Brings up a number pad keyboard in iOS 3.1 and later.

Looks damn near impossible to mess up. However, when I view this simple fiddle on my iPhone or the simulator (both iOS6) the number keypad does not appear, and I get the standard alphabetic keyboard instead.

http://jsfiddle.net/Cy4aC/3/

What on earth could I possibly have messed up here?

enter image description here

like image 603
Alex Wayne Avatar asked Jan 21 '13 21:01

Alex Wayne


People also ask

How do I get my iPhone keyboard to show numbers?

If a keyboard isn't already visible, tap the Show Keyboard button , then tap the Formula Keyboard button to start editing a formula. To enter a number or symbol quickly on an iPad, drag down on a key and then lift your finger, or switch to the numeric keyboard on iPhone.

How do I change my keyboard to number pad on iPhone?

Go to Settings > General > Keyboard > Keyboards. Tap a language at the top of the screen, then select an alternative layout from the list.

How do I type numbers on my Apple keyboard?

When you are typing in iOS 11, you can swipe down on the upper row of letters to add numbers.

Does input type text allow numbers?

By default, HTML 5 input field has attribute type=”number” that is used to get input in numeric format. Now forcing input field type=”text” to accept numeric values only by using Javascript or jQuery. You can also set type=”tel” attribute in the input field that will popup numeric keyboard on mobile devices.


2 Answers

You need to specify the pattern:

<input type="number" pattern="\d*"/> 

As a number can be negative or with floating point, so the - and . and , should be available in the keyboard, unless you specify a digits only pattern.

enter image description here

like image 189
Majid Laissi Avatar answered Sep 28 '22 03:09

Majid Laissi


As of ios 12.2 (released March 25, 2019) this solution will work and it is the simplest to implement

<input type="number" inputmode="decimal"/> 

This will bring up only the number key pad without the #+* characters that come with using input="tel"

like image 33
Aaron Angle Avatar answered Sep 28 '22 03:09

Aaron Angle