Iphone Development - 如何显示数字键盘? [英] Iphone Development - How to display a numeric keyboard?

查看:41
本文介绍了Iphone Development - 如何显示数字键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个移动网站,它不是一个原生 iPhone 应用程序,而是一个用 c# asp.net 开发的简单 m.somedomain.com 网站.

I'm working on a mobile website which is NOT a native iPhone app but rather a simple m.somedomain.com website which is developed in c# asp.net .

目标:单击其中一个文本框时,如何仅显示数字键盘?

Objective : On clicking one of the text boxes how do I display the numeric keyboard only ?

注意:该网站不是 HTML5 格式,也不是本机应用程序内 web 视图的一部分,而是一个独立的常规网站

Note : The website is NOT in HTML5 and is not part of a webview inside a Native app but rather a standalone regular website

我的文本框是一个普通的 asp.net 文本框:

My textbox is a regular asp.net text box :

<asp:TextBox runat="server" CssClass="reference_input" Text="1234567"  />

推荐答案

编辑:我找到了 这里你可以使用

EDIT: I found here that you can use

<input type="text" pattern="[0-9]*"/>

告诉移动 Safari 将数字键盘设置为默认值,无需指定电话键盘.

to tell mobile safari to set the numeric keyboard as default, without needing to specify the telephone keyboard.

EDIT 2(来自下面的评论):您也可以使用 javascript 来强制输入数字:

EDIT 2 (from comments below): You can also use javascript to force numeric input as so:

<input type="text" pattern="[0-9]*" onKeypress="if(event.keyCode < 48 || event.keyCode > 57){return false;}"/>

这篇关于Iphone Development - 如何显示数字键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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