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

2023-02-16移动开发问题
3

本文介绍了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 - 如何显示数字键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7

[ios.cocos2d+box2d]如何禁用自动旋转?
[ios.cocos2d+box2d]how to disable auto-rotation?([ios.cocos2d+box2d]如何禁用自动旋转?)...
2024-08-12 移动开发问题
7