Friday, 28 December 2012

Validating RadioButtonList using JavaScript

write the following code in your .aspx,

<script type="text/javascript">    
function validate()
{
var selected = $('#<%=RadioButtonList1.ClientID %> input:radio:checked').length;
if( selected>0){alert("valid");}
else{alert("Invalid");}
}
</script>

 <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal">
        <asp:ListItem>MALE</asp:ListItem>
        <asp:ListItem>FEMALE</asp:ListItem> </asp:RadioButtonList>



For any other queries feel free to post a comment.

No comments:

Post a Comment