gpt4 book ai didi

javascript - label元素的for属性的值必须是非隐藏表单控件的ID?

转载 作者:行者123 更新时间:2023-11-27 23:00:24 29 4
gpt4 key购买 nike

我正在尝试为类(class)元素创建一个网站。其中一页必须是表格。对于我的表单,当我对标签进行编码时,当我去验证它时,我得到了每个标签的“标签元素的 for 属性的值必须是非隐藏表单控件的 ID”错误,尽管事实上该网站按预期工作。我该如何修复它可以修复吗?这是网页的代码:

<!DOCTYPE html>
<html lang="en">
<head>
<title>In The Know :: Subscribe</title>
<meta charset="utf-8">
<link href="intheknow.css" rel="stylesheet">
<meta name="description" content="InTheKnow.com is your go-to site for whenever you want to catch up on the latest stories about everything from Hollywood happenings to world events.">
</head>
<body>
<div id="container">
<header>
<h1><a href="index.html">InTheKnow.com</a></h1>
</header>
<nav>
<ul>
<li><a href = "index.html">Home</a></li>
<li><a href = "subscribe.html">Subscribe</a></li>
<li><a href = "topics.html">Topics</a></li>
</ul>
</nav>
<main>

<h1>Subscribe To Stay In The Know</h1>

<h2>Knowledge is Power. Get The Power To Stay Ahead.</h2>


<hr>

<figure id="subpagepic">
<img src="fishingboat.jpg" alt="InTheKnow.com" width="200" height="200">
<figcaption> Get your info ship sailing<br>
with a subscription today!</figcaption>
</figure>


<h3>Enter Your Basic Information</h3>

<form method="post" action="mailto:gsingletary4@centralgatech.edu">
<label for="myFirstName"> First Name:</label>
<input type="text" name="myFirstName" required="required">
<label for="myLastName"> Last Name:</label>
<input type="text" name="myLastName" required="required">
<label for="myEmailAddress"> Email Address:</label>
<input type="text" name="myEmailAddress" required="required">

<h3>Choose Your Billing Cycle</h3>

<input type="radio" name="entry" id="entry1">$10/mo <br>
<input type="radio" name="entry" id="entry3">$25/3mo<br>
<input type="radio" name="entry" id="entry6">$50/6mo<br>
<input type="radio" name="entry" id="entry12">$80/12mo<br>

<h3>Choose Your Preferred Payment Method</h3>

<select size="1" name="prefpay" id="prefpay">
<option value="Visa">Visa</option>
<option value="MasterCard">MasterCard</option>
<option value="Discover">Discover</option>
<option value="Chase">Chase</option>
<option value="CapitalOne">Capital One</option>
<option value="AmericanExpress">American Express</option>
</select>

<h3>Preferences/Terms of Service</h3>
<div id="checkbox">
<input type="checkbox" name="notifications" id="notifications" value="yes"> Keep me updated with daily notifications.<br>
<input type="checkbox" name="digital" id="digital" value="yes"> Send me a monthly digital newspaper via email.<br>
<input type="checkbox" name="terms" id="terms" value="yes"> By signing up, you agree to the Terms of Service.<br>
</div>

<h3>Questions/Comments/Concerns?</h3>

<label for="myCommentSection"> Comments: </label>
<textarea name="myCommentSection" id="myCommentSection" rows="3" cols="15"></textarea>
<div id="resetbutton">
<input type="reset">
</div>
<br>
<div id="submitbutton">
<input type="submit" value="Sign me up!">
</div>

</form>


<h3>Questions? Comments? Concerns? Contact us below!</h3>

<div id="contactinfo">
<span class="know">InTheKnow.com</span> <br>
6937 Redwing Drive<br>
Canton, OH 31415<br>
Find us on Facebook: Facebook.com/InTheKnow<br>
Follow us on Twitter: Twitter.com/intheknow<br>
Phone: 987-654-3210<br>
<br>
</div>


</main>
<footer>
Copyright &copy; 2020 InTheKnow.com<br>
<a href="mailto:gsingletary4@centralgatech.edu"></a> gsingletary4@student.centralgatech.edu
</footer>
</div>
</body>
</html>

最佳答案

您的问题发生在您拥有的标签/输入中,您的标签具有 for 属性,但您的输入没有 id 属性。您可以按如下方式解决此问题:

<label for="myFirstName"> First Name:</label>
<input type="text" id="myFirstName" name="myFirstName" required="required">
<label for="myLastName"> Last Name:</label>
<input type="text" id="myLastNamr" name="myLastName" required="required">
<label for="myEmailAddress"> Email Address:</label>
<input type="text" id="myEmailAddress" name="myEmailAddress" required="required">

关于javascript - label元素的for属性的值必须是非隐藏表单控件的ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59024471/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com