問題描述
我正在開發一個移動網站,它不是一個原生 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 - 如何顯示數字鍵盤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!