Iphone Development - 如何显示数字键盘?

Iphone Development - How to display a numeric keyboard?(Iphone Development - 如何显示数字键盘?)
本文介绍了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 - 如何显示数字键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
How to send an image with custom keyboard iOS(如何使用自定义键盘IO发送映像)
Capture barcode reader (keyboard-wedge) events from javascript(从Java脚本捕获条形码读取器(键盘按钮)事件)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)