2016-07-25 42 views
1

我有我的代码中的一些错误 这是我的错误:的为标签元素的属性必须是指一个非隐藏表单控件

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

而且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>

它有什么问题?谢谢!

回答

0

验证程序期望您的标签的for字段指向包含它的输入元素的id字段。在这里,这意味着for="input-5"预计为for="search",因为<input>的ID是search

由于您期望用户将输入添加到此字段,您应该确保它们彼此链接。

2

标签属性必须包含输入ID

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

要省略ID属性都在一起,把输入标签

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

还要注意,输入不能隐藏<input type="hidden">,但它可以为隐藏风格<input style="display:none">

相关问题