搜索
首页web前端css教程您想知道的有关输入模式的一切

您想知道的有关输入模式的一切

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, and latin-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中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
迭代使用样式组件的React设计迭代使用样式组件的React设计Apr 21, 2025 am 11:29 AM

在一个完美的世界中,我们的项目将拥有无限的资源和时间。我们的团队将开始使用经过深思熟虑的UX设计进行编码。

哦,制作三角形面包丝带的许多方法!哦,制作三角形面包丝带的许多方法!Apr 21, 2025 am 11:26 AM

哦,制作三角形面包屑丝带的许多方法

CSS指南中的SVG属性CSS指南中的SVG属性Apr 21, 2025 am 11:21 AM

SVG具有自己的一套元素,属性和属性集,以至于内联SVG代码可能会变得漫长而复杂。通过利用CSS和SVG 2规范的一些即将到来的功能,我们可以减少该代码以进行清洁标记。

交叉观察者的一些功能用途可以知道何时在元素中查看交叉观察者的一些功能用途可以知道何时在元素中查看Apr 21, 2025 am 11:19 AM

您可能不知道这一点,但是JavaScript最近偷偷地积累了许多观察者,而交叉观察者是其中的一部分

恢复偏爱减少运动恢复偏爱减少运动Apr 21, 2025 am 11:18 AM

我们可能不需要扔掉所有CSS动画。请记住,这更喜欢减少动作,而不喜欢不运动。

如何将进步的Web应用程序进入Google Play商店如何将进步的Web应用程序进入Google Play商店Apr 21, 2025 am 11:10 AM

PWA(Progressive Web应用程序)已经与我们在一起了一段时间。但是,每次我尝试向客户解释它时,同样的问题都会出现:“我的用户会成为

处理HTML的最简单方法包括处理HTML的最简单方法包括Apr 21, 2025 am 11:09 AM

这对我来说非常令人惊讶,HTML从未在其中包含其他HTML文件。似乎也没有任何东西

更改悬停在悬停的SVG的颜色更改悬停在悬停的SVG的颜色Apr 21, 2025 am 11:04 AM

使用SVG有很多不同的方法。取决于哪种方式,在不同状态或条件下重新定制该SVG的策略 - 悬停,

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具