[英]The for attribute of the label element must refer to a form control error?
This is driving me crazy. 这真让我抓狂。 I know its something to do with the label tag.
我知道它与标签有关。 here is my code:
这是我的代码:
<form method="post" action="includes/loginprocess.php">
<label for="username">Username: </label>
<input type="text" name="username" value=''/>
<label for="password">Password: </label>
<input type="password" name="password" />
<input type="submit" name="submit" value="submit" />
</form>
The for and name are both the same? for和名字都一样吗?
The error is "The for attribute of the label element must refer to a form control." 错误为“标签元素的for属性必须引用表单控件。”
According to http://www.w3schools.com/tags/att_label_for.asp , the value of for
attribute of a label should be the id
of the element the label is bound to, so add id
attribute to the textboxes 据http://www.w3schools.com/tags/att_label_for.asp ,价值
for
标签的属性应该id
标签绑定到的元素,所以添加id
属性的文本框
<form method="post" action="includes/loginprocess.php">
<label for="username">Username: </label>
<input type="text" name="username" id="username" value=''/>
<label for="password">Password: </label>
<input type="password" name="password" id="password" />
<input type="submit" name="submit" value="submit" />
</form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.