Notice that using input type="number"
can display a numeric keyboard as below:
Is it possible to use input type="text"
to display the same numeric keyboard? I do not want to display a number pad using pattern="\d*"
because it is possible that the value will contain a decimal place.
The reason I would like to use input type="text"
instead of input type="number"
is that I cannot get back the value if I input a non-number for a number field. For example, if I input ABC, it will become empty automatically. It seems to me that using input type="text"
will be easier for this kind of control.
If a keyboard isn't already visible, tap the Show Keyboard button , then tap the Formula Keyboard button to begin editing a formula. To quickly enter a number or symbol on an iPad, drag down on a key and then lift your finger, or switch to the numeric keyboard on iPhone.
About Numpad Just tap the additional keyboards button to access Numpad.
If your input is a true number, integer or decimal then use the HTML5 type="number"
input. This will bring up correct keyboard on Android devices (assume Windows phone too).
Then the trick is to place a pattern="[0-9]*"
on that attribute to force the special numeric keypad on iOS. Note that:
One last note, be sure NOT TO use the type number field for inputs that are not true numbers (eg. zipcodes with leading zeros or product codes with comas or spaces). A numeric input field MAY NOT SUBMIT values that are not true numbers! (depending on browser/device)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With