我有这样的表格:
<form id="br" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]) ?>">
<table>
<tr>
<td>Report Title:*</td> <td><input name="title" type="text" required placeholder="The bug that you want to report" size="50" maxlength="35" /></td><td></td>
</tr><br />
<tr>
<td>Reporter:*</td> <td><input name="user" type="text" required class="username" placeholder="Your name" size="50" maxlength="35"></td><td><input type="checkbox" name="anonymous" id="cb" /><label for="cb">Report anonymously</label></td>
</tr>
<tr>
<td style="vertical-align: top;">Report summary:* </td> <td><textarea name="sum" cols="39" rows="15" required id="sum"></textarea></td></td><td></td>
</tr>
<tr><td style="font-size:12px;"><em>* - required field</em></td><td></td><td></td></tr>
</table>
<br />
<a href="#" class="submit"><div class="submitform"></div></a>
<br />
</form>
但即使我将required
属性放入其中,必填字段也不会验证。它会立即提交表格而不再进行验证......
答案 0 :(得分:0)
<a href="#" class="submit"><div class="submitform"></div></a>
应该是
<input type="submit" name="submit" />