当没有选择任何单选按钮时,我需要一个警报来显示。
html代码:
<tr>
<td><input id="Radio1" name="delivery" value="M" type="radio">M</td>
</tr>
<tr>
<td><input id="Radio2" name="delivery" value="P" type="radio">P</td>
</tr>
<tr>
<td><input id="Radio3" name="delivery" value="S" type="radio">S</td>
</tr>
Javascript:
deliveryChecked = ""
for (i = 0; i < f.deliveryChecked; i++) {
if (f.deliveryChecked[i].checked) {
deliveryChecked = f.delivery[i].value
break
}
}
if (deliveryChecked == "") {
alert("You did not make a delivery selection!")
return false
}