<script type = "text/javascript">
function Validate() {
var RB1 = document.getElementById("<%=RadioButtonList1.ClientID%>");
var radio = RB1.getElementsByTagName("input");
var isChecked = false;
for (var i = 0; i < radio.length; i++) {
if (radio[i].checked) {
isChecked = true;
break;
}
}
if (!isChecked) {
alert("Please select an option in each question");
}
return isChecked;
}
</script>
Control:
<asp:RadioButtonList ID="RadioButtonList1" repeatdirection="Vertical" runat="server">
<asp:ListItem Value="Yes"></asp:ListItem>
<asp:ListItem Value="No"></asp:ListItem>
</asp:RadioButtonList>
|