RadioButtonList CustomValidator
<p>Could someone help me validate this radio buttonlist in asp.net Im using a customvalidator with clientide script. I can't get it wqorking for some reason</p>

<pre><code>&lt;asp:RadioButtonList ID="radioGender" runat="server"
                            RepeatDirection="Horizontal"&gt;
                            &lt;asp:ListItem Value="Male" Text="Male" /&gt;
                            &lt;asp:ListItem Value="Female" Text="Female" /&gt;
                        &lt;/asp:RadioButtonList&gt;
                        &lt;asp:CustomValidator ID="valGender" runat="server"
                            ValidateEmptyText="true" 
                            ClientValidationFunction="validateGender"
                            Display="Dynamic"
                            ErrorMessage="Please choose you're gender."
                            ValidationGroup="UserInfo"&gt;*&lt;/asp:CustomValidator&gt;
                        &lt;script language="javascript" type="text/javascript"&gt;
                            function validateGender(source, args) {
                                var radGender = document.getElementById("&lt;%= radioGender.ClientID  %&gt;");
                                var elements = radGender.getElementsByTagName("input");
                                var selected = false;

                                for (var i = 0; i &lt; elements.length; i++) {
                                    if (elements[i].checked == true) {
                                        selected = true;
                                        break;
                                    }
                                }

                                if (!selected) {
                                    args.isValid = false;
                                    return args.isValid;
                                } else {
                                    args.isValid = true;
                                    return args.isvalid;
                                }
                            }
                        &lt;/script&gt;
</code></pre>

<p>Updated:</p>

<pre><code>&lt;table border="0" cellpadding="0" cellspacing="0"&gt;
                            &lt;tr&gt;
                                &lt;td&gt;
                                    &lt;asp:RadioButtonList ID="radioGender" runat="server" ValidationGroup="UserInfo" Width="130px"
                                        RepeatDirection="Horizontal"&gt;
                                        &lt;asp:ListItem Value="Male" Text="Male" /&gt;
                                        &lt;asp:ListItem Value="Female" Text="Female" /&gt;
                                        &lt;asp:ListItem Value="None" Text="None" Selected="True" style="display:none; width:0px" /&gt;
                                    &lt;/asp:RadioButtonList&gt;
                                &lt;/td&gt;
                                &lt;td align="left"&gt;
                                    &lt;asp:CustomValidator ID="valGender" runat="server"                                
                                        ControlToValidate="radioGender"
                                        ClientValidationFunction="validateGender"
                                        ErrorMessage="Please select you're gender." EnableClientScript="true"
                                        ValidationGroup="UserInfo" Display="Dynamic" style="margin-left:-5px"&gt;*&lt;/asp:CustomValidator&gt;     
                                    &lt;script language="javascript" type="text/javascript"&gt;
                                        function validateGender(source, args) {
                                            var radGender = document.getElementById("&lt;%= radioGender.ClientID  %&gt;");
                                            var elements = radGender.getElementsByTagName("input");
                                            var selected = false;


                                            for (var i = 0; i &lt; elements.length; i++) {
                                                if (elements[i].checked &amp;&amp; elements[i].value == "None") {
                                                    selected = true;
                                                    break;
                                                }
                                            }

                                            if (selected) {
                                                args.IsValid = false;
                                                return false;
                                            } else {
                                                args.IsValid = true;
                                                return true;
                                            }

                                        }
                                    &lt;/script&gt;
                                &lt;/td&gt;
                            &lt;/tr&gt;
                        &lt;/table&gt;
&lt;asp:Button ID="btnSubmitProfile" runat="server"
    Text="Save" OnClick="btnSubmitProfile_Click" ValidationGroup="UserInfo" /&gt;
&lt;asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="UserInfo" /&gt;
</code></pre>
