使用html使用大写字母打开android和ios键盘 [英] open android and ios keyboard with uppercase using html

查看:90
本文介绍了使用html使用大写字母打开android和ios键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为移动设备创建一个网页.因为很少有输入字段要求用户始终以大写形式输入数据.

i am creating a web page for mobile devices. In that there are few input fields which require user to always enter data in uppercase.

我看过一些类似

    CSS的
  1. text-transform 属性
    它将用户输入更改为大写,但同时也更改了占位符.看起来不太好.
  2. 输入的
  3. autocapitalize 属性
    通过将其设置为打开,可以使键盘以大写字母形式打开.但这似乎对我不起作用.它与 textarea 完美搭配,但不适用于android中的 input .
  1. text-transform property of css
    It changes user input to uppercase but it also changes the placeholder. That doesn't looks good.
  2. autocapitalize attribute for input
    By setting it on, it allows keyboard to open in caps. But this doesn't seems to work for me. It works perfectly with textarea but not with input in android.

有没有更好的方法来实现这一目标?

Is there any better way to achieve this?

推荐答案

尝试向 input 添加 autocapitalize ="characters" ,它在Android上对我有效应MDN网络文档说此处:

try adding autocapitalize="characters" to input, it worked for me on Android, and it should work on other kind of devices as MDN web docs says here:

自动大写属性在输入时不影响行为物理键盘.相反,它会影响其他输入的行为机制,例如移动设备上的虚拟键盘和语音输入.

The autocapitalize attribute doesn’t affect behavior when typing on a physical keyboard. Instead, it affects the behavior of other input mechanisms, such as virtual keyboards on mobile devices and voice input.

这篇关于使用html使用大写字母打开android和ios键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆