我很难获得JavaScript
我目前的代码如下:
<body>
<script type="text/javascript">
if((document.form1.gender[0].checked===false) &&(document.form1.gender[1].checked===false))
{
alert("You must make a choice");
}
function isOneChecked() {
var chx = document.getElementsByTagName("input");
for (i=0; i<chx.length; i+++++) {
if (chx[i].type == "radio" && chx[i].checked) {
return true;
}
}
alert("You must select at least one");
}
</script>
<p>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
</p>
<p>Select all sport interests that apply.</p>
<input type="checkbox" name="chkSport" value="football" />Football<br />
<input type="checkbox" name="chkSport" value="baseball" />Baseball<br />
<input type="checkbox" name="chkSport" value="basketball" />Basketball<br />
<input type="checkbox" name="chkSport" value="soccer" />Soccer<br />
<input type="checkbox" name="chkSport" value="trackandfield" />Track and Field<br />
<input type="checkbox" name="chkSport" value="none" />None<br />