Validate Radiobuttonlist using Javascript
Hi i have a radiobutton list placed inside an update panel.I can get an alert with JavaScripting when the radiobuttonlist is not selected.but the problem is that when i check the radiobuttonlist and click the save button i get the same message.what's problem?.
how do i achieve this.
All suggestions are much appreciated
Thanks in advance
the javascript code given below
<script language="javascript" type="text/javascript">
function ValidateRadioTable()
{
var rb2 = document.getElementById('<%=rdTable.ClientID%>');
var radio_choice2 = false;
for (counter2 = 0; counter2 < rb2.length; counter2++)
{
if (rb2[counter2].checked)
{
radio_choice2 = true;
break;
}
}
if (radio_choice2==false)
{
alert("Please select Table Booking Yes or No.")
event.returnValue=false;
return false;
}
return false;
}
</script>
----------------------------
<asp:RadioButtonList ID="rdTable" runat="server" AutoPostBack="True" Font-Size="10pt"
RepeatDirection="Horizontal" Width="110px">
<asp:ListItem>Yes</asp:ListItem>
<asp:ListItem>No</asp:ListItem>
</asp:RadioButtonList></td>
|