[英]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 要完全省略for和id属性,请将输入内容放在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.