我的代码中有一些错误--这里是我的错误:
label元素的for属性必须引用非隐藏的窗体控件。
我的密码是:
<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>
这是怎么回事?谢谢!
发布于 2017-06-30 10:43:50
属性的标签必须包含输入id值。
<label for="foo">Foo:</label>
<input id="foo">若要将for和id属性全部省略,请将输入放入标签中。
<label>
Foo: <input name="foo">
</label>还要注意的是,输入不能是隐藏的 <input type="hidden">,但是可以将其设计为隐藏<input style="display:none">。
发布于 2017-06-02 16:32:02
验证器期望标签的for字段以包含它的输入元素的id字段为目标。在这里,这意味着for="input-5"应该是for="search",因为<input>的id是search。
当您期望用户将输入添加到此字段时,您应该确保它们是相互链接的。
https://stackoverflow.com/questions/38569235
复制相似问题