inputmode
屬性為觸摸屏設備上的瀏覽器提供了一個有價值的提示,從而指導它們選擇適當的屏幕鍵盤<input>
和<textarea></textarea>
elements. Unlike altering the input type, inputmode
solely dictates keyboard display, not input interpretation.
While possessing a lengthy history, widespread adoption by major mobile browsers (Safari and Chrome) is relatively recent. Prior implementations in Firefox for Android were short-lived. This support, detailed on caniuse.com, shows version-specific compatibility. Note that my testing suggests Opera Mini and Opera Mobile support contradicts caniuse data.
Although the WHATWG specification documents inputmode
, the W3C 5.2 spec omits it, hinting at potential obsolescence. However, given WHATWG documentation and browser support, we'll consider the WHATWG standard.
inputmode
accepts several values:
none
This value prevents keyboard display in Chrome for Android, though iOS 12.2 shows its default keyboard. It's intended for inputs with custom keyboard controls.
numeric
Highly useful for numerical inputs (PINs, zip codes, etc.). Unlike type="number"
, it allows maxlength
, minlength
, and pattern
attributes, enhancing versatility. While often used with type="tel"
, this is semantically incorrect. The pattern="\d*"
attribute provides a similar effect but limits input strictly to numbers; Android doesn't allow switching to an alphanumeric keyboard, potentially blocking valid entries.
tel
Optimizes telephone number input. It provides a standard telephone keypad (0-9, #, *) with alphabetic mnemonics (ABC, DEF, etc.).
decimal
Produces a keyboard similar to tel
on iOS, replacing the * # key with a decimal point. Android uses the standard numeric keyboard.
email
Includes the @
and .
characters, improving email address entry. iOS's email suggestions might cause confusion. Useful for custom email validation.
url
Facilitates URL entry by including common web address characters (.
, /
) and locale-specific TLDs. Use type="url"
for input validation.
search
Displays a "Go" (iOS) or "Enter" (Android) key, ideal for search forms. type="search"
offers alternative visual cues.
Additional Notes
- Chromium-based Android browsers (Edge, Brave, Opera) mirror Chrome's
inputmode
behavior. - iPad and Android tablet behavior largely mirrors iPhone and Android phones, respectively, excluding third-party keyboards.
-
kana
,katakana
, andlatin-name
values from earlier specifications are no longer implemented. Interestingly,latin-name
on iOS suggests the user's name.
Demo
A live demo showcasing these inputmode
variations is available (link to be provided if a demo is created).
References
- WHATWG specification
- MDN documentation
- caniuse.com
- Chrome Platform Status (Chromium Ticket #244688)
以上是您想知道的有關輸入模式的一切的詳細內容。更多資訊請關注PHP中文網其他相關文章!

對於Astro,我們可以在構建過程中生成大部分網站,但是有一小部分服務器端代碼可以使用Fuse.js之類的搜索功能來處理搜索功能。在此演示中,我們將使用保險絲搜索一組個人“書籤”


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

Dreamweaver Mac版
視覺化網頁開發工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中