Wednesday, August 3, 2011

Validation in Radiobutton List


<script language="javascript" type="text/javascript">

 function ValidateRadioButtonListSIALenece() {
            var RBL = document.getElementById('<%= RbtnSIA.ClientID %>');
            var radiobuttonlist = RBL.getElementsByTagName("input");
            var counter = 0;
            var atLeast = 1;
            for (var i = 0; i < radiobuttonlist.length; i++) {
                if (radiobuttonlist[i].checked) {

                    if (radiobuttonlist[i].value == "Yes") {
                        // alert('y');
                        document.getElementById("<%=txtDateOfApplication.ClientID %>").value = "";
                        document.getElementById("<%=txtDateOfApplication.ClientID %>").readOnly = false;
                        document.getElementById("<%=Img29.ClientID %>").style.visibility = 'visible';
                        document.getElementById("<%=RegularExpressionValidator10.ClientID %>").readOnly = false;
                    }
                    if (radiobuttonlist[i].value == "No") {
                        // alert('N');
                        document.getElementById("<%=txtDateOfApplication.ClientID %>").value = "";
                        document.getElementById("<%=txtDateOfApplication.ClientID %>").readOnly = true;
                        document.getElementById("<%=Img29.ClientID %>").style.visibility = 'hidden';
                        document.getElementById("<%=RegularExpressionValidator10.ClientID %>").readOnly = true;

                    }

                    counter++;
                }
            }
        }
</script>

I am calling this on radiobutton list click event
this.RBtnList.Attributes.Add("OnClick", "javascript:return  ValidateRadioButtonListSIALenece();");

No comments:

Post a Comment