Hi. Suppose you have 3 Radiobuttons.. You will be validating on some button control. Please find below how to do it step by step.
Step1: Setup your radio buttons on aspx page.
<strong> Some Heading</strong> <asp:RadioButton ID="Radio1" GroupName="Flag" runat="server" Text="DNR" /> <asp:RadioButton ID="Radio2" GroupName="Flag" runat="server" Text="RE" /> <asp:RadioButton ID="Radio3" GroupName="Flag" runat="server" Text="RI" />
Step2: You have to declare some button/imagebutton or somthing else to validate. I suppose you have button cmdSave for validation.
Step3: in code behind of page On Page Load, you have to call javascript function of validation. i.e
cmdSave.Attributes.Add("onClick", "Javascript:checkFlag()");
Step4: You have to declare function checkFlag() in your aspx page. i.e
function checkFlag() { event.returnValue = false; var DNR = document.getElementById('<%= RadioDNR.ClientID %>').checked; var RE = document.getElementById('<%= RadioRE.ClientID %>').checked; var RI = document.getElementById('<%= RadioRI.ClientID %>').checked; if (DNR == false && RE == false && RI == false) { alert ('Please Specify one of the Flags'); } else { event.returnValue = true; } }