简体   繁体   English

label元素的for属性是否必须引用表单控件错误?

[英]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.

相关问题 验证HTML时出错:label元素的for属性必须引用表单控件 - Error validating HTML: 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? label元素的for属性必须引用非隐藏表单控件 - The for attribute of the label element must refer to a non-hidden form control 验证HTML:label元素的for属性必须引用表单控件 - validating HTML: The for attribute of the label element must refer to a form control 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 为什么会出现这个错误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 标签元素的for属性的值必须是非隐藏表单控件的ID吗? - The value of the for attribute of the label element must be the ID of a non-hidden form control? 为什么label元素具有表单属性? - Why does the label element have a form attribute? 必须HTML <form> 动作属性绝对引用.php文件发送表单数据? - Must the HTML <form> action attribute absolutely refer to a .php file to send form data?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM