【发布时间】:2017-05-01 06:47:35
【问题描述】:
这是我的表格。我需要在 JavaScript 中进行验证。 在验证中至少选择了一个复选框。 我希望你们都明白我需要什么。 请给我解决方案。 如果有任何疑问,请随时询问。
<form action="#" method="post" name="studentregistration" onsubmit="return(validate());">
<table cellpadding="3" width="100%" align="center" cellspacing="3">
<tr>
<td>Hobby</td>
<td>
<input type="checkbox" name="hobby" value="Chess" id="hobby">Chess
<input type="checkbox" name="hobby" value="Music" id="hobby">Music<br>
<input type="checkbox" name="hobby" value="Cricket" id="hobby">Cricket
<input type="checkbox" name="hobby" value="Reading" id="hobby">Reading
</td>
</tr>
<tr>
<td>
<input type="submit" name="Submit Form" value="Submit Form" id="submitform">
</td>
</tr>
</table>
</form>
【问题讨论】:
-
我需要在选择框中至少选择一个
-
您使用提交表单的方式,是否选中复选框都没有关系。验证后才能提交表单。
标签: javascript jquery html css function