Iphone Development - How to display a numeric keyboard?(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 - 如何显示数字键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Iphone Development - 如何显示数字键盘?
基础教程推荐
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
