Question : Java validation for radio button list

Hi, I have been requested to put Java validation on a set of radio buttons in an aspx / C# form. I used before the <asp: requiredFieldValidator" but client prefer to have a pop up window,, could someone tell me how the script would look like...

<asp:RadioButtonList ID="RadioButtonList1" repeatdirection="Vertical" runat="server">
               
                    <asp:ListItem Value="Yes"></asp:ListItem>
                    <asp:ListItem Value="No"></asp:ListItem>
                 </asp:RadioButtonList>
...
<asp:RadioButtonList ID="RadioButtonList9" repeatdirection="Vertical" runat="server">
               
                    <asp:ListItem Value="Yes"></asp:ListItem>
                    <asp:ListItem Value="No"></asp:ListItem>
                 </asp:RadioButtonList>
...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
<asp:Table ID="Table1" CellPadding="15" CellSpacing="0" HorizontalAlign="Center" GridLines="Both"  runat="server">



            <asp:TableRow CssClass="alt2">
                <asp:TableCell>1</asp:TableCell>
                <asp:TableCell>Informed consent signed by patient/designee and physician</asp:TableCell>
                <asp:TableCell>
                <asp:RadioButtonList ID="RadioButtonList1" repeatdirection="Vertical" runat="server">
                
                    <asp:ListItem Value="Yes"></asp:ListItem>
                    <asp:ListItem Value="No"></asp:ListItem>
                 </asp:RadioButtonList>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"  ControlToValidate="RadioButtonList1" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                
            </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow  CssClass="alt">
                <asp:TableCell>2</asp:TableCell>
                <asp:TableCell><b>History & Physical - Contains the following:</b><br />Chief complaint, history of present illness heart/lung assessment</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList2" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"  ControlToValidate="RadioButtonList2" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            
            <asp:TableRow CssClass="alt2">
                <asp:TableCell>3</asp:TableCell>
                <asp:TableCell><br /><b>History & Physical - Meets one of the following criteria:</b><br />Signed/dated within 24 hrs of addmision<br />Less than 30 days old with update note/date/signature or progress note within 24 hrs?</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList3" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"  ControlToValidate="RadioButtonList3" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            
            <asp:TableRow CssClass="alt">
                <asp:TableCell>4</asp:TableCell>
                <asp:TableCell><b>"TIME OUT" performed & includes the following:</b><br />Confirmation of identity, side/site, consent form, procedure, need for abx/fluids, safety precautions when applicable</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList4" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"  ControlToValidate="RadioButtonList4" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow CssClass="alt2">
                <asp:TableCell>5</asp:TableCell>
                <asp:TableCell><b>Site Marking</b> - Operative site marked</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList5" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                        <asp:ListItem Value="N/A"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server"  ControlToValidate="RadioButtonList5" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow  CssClass="alt">
                <asp:TableCell>6</asp:TableCell>
                <asp:TableCell>Anesthesia assessment performed?</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList6" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                        <asp:ListItem Value="N/A"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server"  ControlToValidate="RadioButtonList6" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow CssClass="alt2">
                <asp:TableCell>7</asp:TableCell>
                <asp:TableCell>Are all medications, medication containers or other solutions labeled?</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList7" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                        <asp:ListItem Value="N/A"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server"  ControlToValidate="RadioButtonList7" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow  CssClass="alt">
                <asp:TableCell>8</asp:TableCell>
                <asp:TableCell>Is immediate physician's post op note present?</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList8" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server"  ControlToValidate="RadioButtonList8" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
            <asp:TableRow CssClass="alt2">
                <asp:TableCell>9</asp:TableCell>
                <asp:TableCell>Is the post op note completed and to include date, time, and signature?</asp:TableCell>
                <asp:TableCell>
                    <asp:RadioButtonList ID="RadioButtonList9" repeatdirection="Vertical" runat="server">
                        <asp:ListItem Value="Yes"></asp:ListItem>
                        <asp:ListItem Value="No"></asp:ListItem>
                    </asp:RadioButtonList>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server"  ControlToValidate="RadioButtonList9" ErrorMessage="* Required"></asp:RequiredFieldValidator>
                </asp:TableCell>
            </asp:TableRow>
        </asp:Table>

Answer : Java validation for radio button list

<asp:LinkButton ID="lbnGeneral" runat="server" CssClass="leftmenu_link" OnClick="lbnGeneral_Click" OnClientClick="return ValidateCategory();" ValidationGroup="AddTopic" >General</asp:LinkButton>




function ValidateCategory()
{
var rbnCategories= document.getElementById ("<%= rblCategory.ClientID %>");
     var rbnCategoryList= rbnCategories.getElementsByTagName("input");
     var checkCount = false;
     for(var i=0;i<rbnCategoryList.length;i++)
        {  
            if(rbnCategoryList[i].checked)
            {
                checkCount = true;
      break;

            }
        }
       
        if(checkCount)
        {
      return true;
        }
        else
        {

      alert("please select atleast one option");
             return false;    
        }
}
Random Solutions  
 
programming4us programming4us