简体   繁体   English

label元素的for属性必须引用非隐藏表单控件

[英]The for attribute of the label element must refer to a non-hidden form control

I have some errors in my code Here is my error: 我的代码中有一些错误这是我的错误:

The for attribute of the label element must refer to a non-hidden form control. label元素的for属性必须引用非隐藏表单控件。

And myd code: 和myd代码:

 <form action="/search"> <span class="input input--hoshi search-wrapp main-page-open" style="display:block"> <input class="input__field input__field--hoshi" type="text" id="search" name="keyword" placeholder="Search..."/> <label class="input__label input__label--hoshi input__label--hoshi-color-2" for="input-5"> <!--<span class="input__label-content input__label-content-hoshi">Search...</span>--> </label> <span class="icon-serch"></span> </span> <input id="search-btn" type="submit" style="display: none;"/> </form> 

What is wrong with it? 怎么了 Thanks! 谢谢!

The label for attribute must contain the input id value 属性的标签必须包含输入ID

<label for="foo">Foo:</label>
<input id="foo">

To omit the for and id attributes all-together, put input inside label 要完全省略forid属性,请将输入内容放在label内

<label>
    Foo: <input name="foo">
</label>

Also note, that input cannot be hidden <input type="hidden"> , however it can be styled as hidden <input style="display:none"> 还要注意, 输入不能隐藏 <input type="hidden"> ,但是可以将其设置为隐藏的<input style="display:none">

The validator is expecting for your label's for field to target the id field of the input element that contains it. 验证程序期望标签的for字段以包含它的输入元素的id字段为目标。 Here, that means that for="input-5" is expected to be for="search" , as <input> 's id is search . 在这里,这意味着for="input-5"应该是for="search" ,因为<input>的id是search

As you're expecting the user to add input to this field, you should be making sure they are linked to each other. 期望用户将输入添加到该字段时,应确保他们彼此链接。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 label元素的for属性必须引用非隐藏表单控件<label for=“Country” >Countr</label> - The for attribute of the label element must refer to a non-hidden form control <label for=“Country” >Countr 表单中的Textarea标签:错误:标签元素的for属性值必须是非隐藏表单控件的ID - Textarea Label in Form: Error: The value of the for attribute of the label element must be the ID of a non-hidden form control 标签元素的for属性的值必须是非隐藏表单控件的ID吗? - The value of the for attribute of the label element must be the ID of a non-hidden form control? 为什么会出现这个错误label元素的for属性值必须是非隐藏表单控件的ID - Why am I getting this error The value of the for attribute of the label element must be the ID of a non-hidden form control label元素的for属性必须引用表单控件吗? - The for attribute of the label element must refer to a form control? label元素的for属性是否必须引用表单控件错误? - The for attribute of the label element must refer to a form control error? 验证HTML时出错:label元素的for属性必须引用表单控件 - Error validating HTML: The for attribute of the label element must refer to a form control 验证HTML:label元素的for属性必须引用表单控件 - validating HTML: The for attribute of the label element must refer to a form control 选择表单中的第一个非隐藏输入 - Selecting the first non-hidden input in a form 触发单击非隐藏输入字段 - Trigger click on non-hidden input field
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM