< input type =" number" />在iOS上不显示数字键盘 [英] <input type="number"/> is not showing a number keypad on iOS

查看:97
本文介绍了< input type =" number" />在iOS上不显示数字键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Apple的文档安装输入元素的类型 number 我应该得到一个数字键盘。

 < input type =number/> 




number
用于指定数字的文本字段。在iOS 3.1及更高版本中添加一个数字键盘键盘。


看起来几乎不可能搞砸。但是,当我在iPhone或模拟器(iOS6)上查看这个简单的小提琴时,数字键盘不会出现,而是我得到标准的字母键盘。



< a href =http://jsfiddle.net/Cy4aC/3/> http://jsfiddle.net/Cy4aC/3/



什么在地球上我可能已经搞砸了吗?



解决方案

您需要指定模式:

 < input type =numberpattern =\ d */> 

作为数字也可能是否定的或带有浮点数,所以除非您指定只有数字的模式,否则应该在键盘中使用 - p>


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?

解决方案

You need to specify the pattern:

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

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

这篇关于&lt; input type =&quot; number&quot; /&gt;在iOS上不显示数字键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆