*注意:我正在运行Google Chrome版本45
" required =' required'" HTML属性在过去对我来说完美无缺,但现在我遇到的问题是这个属性根本不起作用。我只是想知道我犯了什么(简单)的错误,因为我无法解决我的生活。
以下是表格:
<div class="register_wrap">
<h2 style="font-size: 26px; color: #999; font-weight: normal;">Register your team to play in an upcoming Oceanic eSports tournament</h2>
<form action="enter_a_tournament.php" method="POST" enctype="multipart/form-data">
<label style="font-size: 18px;">Team Name</label><br /><input placeholder="Team Name" type="text" name="team_name" size="48" required="required"/><br /><br />
<label>Player 1</label><br /><input placeholder="In Game Leader" type="text" name="player1" size="48" required="required"/><br /><br />
<label>Player 2</label><br /><input placeholder="AWP'er" type="text" name="player2" size="48" required="required"/><br /><br />
<label>Player 3</label><br /><input placeholder="Entry Fragger" type="text" name="player3" size="48" required="required"/><br /><br />
<label>Player 4</label><br /><input placeholder="Support Fragger" type="text" name="player4" size="48" required="required"/><br /><br />
<label>Player 5</label><br /><input placeholder="Lurk Fragger" type="text" name="player5" size="48" required="required"/><br /><br />
<h2 style="font-size: 22px; color: #999; font-weight: normal;">Extra Team Information</h2>
<label>Team Leader Steam ID</label><br /><input placeholder="Enter Team Leader Steam ID" type="text" name="team_leader" size="48" required="required"/><br /><br />
<label>Steam Group URL</label><br /><input placeholder="Enter Steam Group URL" type="text" name="steam_group" size="48" required="required"/><br /><br />
<label>Website URL</label><br /><input placeholder="Enter Website URL" type="text" name="steam_group" size="48" /><label style="font-size: 13px; color: red;"> *Optional</label><br /><br />
</form>
</div>
答案 0 :(得分:1)
required
属性仍然有效。但是您的表单缺少提交按钮。浏览器不提交没有提交按钮的表单,因此也不会验证任何输入。
添加提交按钮(input[type="submit"]
或button[type="submit"]
或button
[没有类型的按钮元素也是提交按钮]):
<div class="register_wrap">
<h2 style="font-size: 26px; color: #999; font-weight: normal;">Register your team to play in an upcoming Oceanic eSports tournament</h2>
<form action="enter_a_tournament.php" method="POST" enctype="multipart/form-data">
<label style="font-size: 18px;">Team Name</label><br /><input placeholder="Team Name" type="text" name="team_name" size="48" required="required"/><br /><br />
<label>Player 1</label><br /><input placeholder="In Game Leader" type="text" name="player1" size="48" required="required"/><br /><br />
<label>Player 2</label><br /><input placeholder="AWP'er" type="text" name="player2" size="48" required="required"/><br /><br />
<label>Player 3</label><br /><input placeholder="Entry Fragger" type="text" name="player3" size="48" required="required"/><br /><br />
<label>Player 4</label><br /><input placeholder="Support Fragger" type="text" name="player4" size="48" required="required"/><br /><br />
<label>Player 5</label><br /><input placeholder="Lurk Fragger" type="text" name="player5" size="48" required="required"/><br /><br />
<h2 style="font-size: 22px; color: #999; font-weight: normal;">Extra Team Information</h2>
<label>Team Leader Steam ID</label><br /><input placeholder="Enter Team Leader Steam ID" type="text" name="team_leader" size="48" required="required"/><br /><br />
<label>Steam Group URL</label><br /><input placeholder="Enter Steam Group URL" type="text" name="steam_group" size="48" required="required"/><br /><br />
<label>Website URL</label><br /><input placeholder="Enter Website URL" type="text" name="steam_group" size="48" /><label style="font-size: 13px; color: red;"> *Optional</label><br /><br />
<button type="submit">Submit</button>
</form>
</div>