输入元素上的 Autocapitalize 属性(用于 iOS)会破坏验证

发布于 2024-10-22 02:41:05 字数 849 浏览 1 评论 0原文

正如此处所示,Safari 和 iPhone 版 Safari 支持所有 HTML 元素,包括已弃用的元素,甚至是一些从未属于任何 W3C 规范的专有元素。

实际上,在表单的“电子邮件”和“网站”字段中包含 autocapitalize 非常有用,因为没有什么比在填写这两个输入中的任何一个时必须取消选择 SHIFT 键更烦人的了。这样做很简单,因为您需要做的就是将 autocapitalize=off 属性添加到相应的输入,例如:

<label for="email">E-mail</label>
<input type="email" name="email" placeholder="[email protected]" autocapitalize="off" title="Enter your e-mail address" class="required email" id="email">

iPhone 和 iPad 都将键盘与表单中附加到输入元素的属性完美匹配。不幸的是,这个标记似乎破坏了验证,当设置上述内容时,W3C 会响应“此时元素输入不允许属性自动大写”。

我想这并不是什么值得死的事情,但是有没有一种方法可以在不破坏验证的情况下包含这些属性?也许我这里出了什么问题。

As can be seen here, Safari and Safari for the iPhone support all HTML elements, including deprecated elements and even some proprietary elements that were never part of any W3C specifications.

It's actually very useful including autocapitalize in the 'email' and 'website' fields in forms, as there's nothing so annoying as having to unselect the SHIFT key when filling in either of those two inputs. Doing this is trivial as all you need to do is add the autocapitalize=off attribute to the corresponding input, e.g.:

<label for="email">E-mail</label>
<input type="email" name="email" placeholder="[email protected]" autocapitalize="off" title="Enter your e-mail address" class="required email" id="email">

Both the iPhone and the iPad perfectly match keyboards to the attributes attached to the input element in forms. Unfortunately, this markup seems to break validation, with W3C responding with 'Attribute autocapitalize not allowed on element input at this point' when the above is set.

I suppose this isn't something to die for, but is there a way of including the attributes without breaking validation? Maybe I've got something wrong here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

帅的被狗咬 2024-10-29 02:41:05

ughoavgfhw 的评论完全回答了这个问题:按照目前的 W3C 规范,您不能在不破坏验证的情况下在表单中包含 autocapitalize 属性,因此需要权衡这种不便与用户必须摸索浏览表单的情况在 iOS 上的 SHIFT 键上。

我认为这是一种罕见的情况(内联样式是另一种情况),在这种情况下,容忍一页上的错误是有意义的,只要它们不是出现任何问题的症状,而只是 W3C 在页面上有点慢。吸收。

The comment by ughoavgfhw fully answers the question: as W3C specs stand at present, you can't include the autocapitalize attribute in your forms without breaking validation, so it's a case of weighing that inconvenience against that of users having to fumble through your forms clicking on the SHIFTkey on iOS.

I think this is one of those rare cases (inline styles being another) where it makes sense to put up with errors on one page, so long as they aren't symptomatic of anything gone wrong but just of W3C being a bit slow on the uptake.

弃爱 2024-10-29 02:41:05

您不能只向输入元素添加一个类吗?并使用属性 text-transform:lowercase 引用该类?

couldnt you just add a class, to the input element. And reference that class with attribute, text-transform:lowercase ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文