Monday, 17 September 2012

Radio button validation


  <asp:Button ID="btnStep3" CssClass="btn-continue" runat="server" Text="Continue" OnClientClick="return validateRadio();" ValidationGroup="SignUP" OnClick="btnStep3_Click" />
            <script type="text/javascript">
                function validateRadio() {
                    var ErrorMessage = '';
                   // var ErrorMessage1 = '';
                    var GvId = document.getElementById('<%=TxtbxGvtID.ClientID%>');
                    //debugger;
                    if (GvId.value.length == 0) {
                        ErrorMessage = "Please enter Government ID \n";
                    } else if (isNaN(parseInt(GvId.value))) {
                    ErrorMessage += "Please Enter Numeric Value in Govt Id \n";
                                     
                    }          
               
                var Ck1 = document.getElementById('<%=rbn1Year.ClientID %>');
                //debugger;
                var Ck2 = document.getElementById('<%=rb2Year.ClientID %>');
                var Ck3 = document.getElementById('<%=rbing3to5years.ClientID %>');
                var Ck4 = document.getElementById('<%=rbingMoreThan5years.ClientID %>');

                var Ck5 = document.getElementById('<%=rbOptionExperienceLessThan1year.ClientID %>');
                var Ck6 = document.getElementById('<%=rbOptionExperience1to2years.ClientID %>');
                var Ck7 = document.getElementById('<%=rbOptionExperience3to5years.ClientID %>');
                var Ck8 = document.getElementById('<%=rbOptionExperienceMoreThan5Years.ClientID %>');


                var Ck9 = document.getElementById('<%=rbExperienceLessThan1Yers.ClientID %>');
                var Ck10 = document.getElementById('<%=rbExperience1to2years.ClientID %>');
                var Ck11 = document.getElementById('<%=rbExperience3to5years.ClientID %>');
                var Ck12 = document.getElementById('<%=rbCDFTradingExperienceMoreThan5Years.ClientID %>');

                var Ck13 = document.getElementById('<%=rbExperienceLessThan1Year.ClientID %>');
                var Ck14 = document.getElementById('<%=rbExperience1to2years.ClientID %>');
                var Ck15 = document.getElementById('<%=rbExperience3to5years.ClientID %>');
                var Ck16 = document.getElementById('<%=rbFutresMoreThan5Years.ClientID %>');

                var Ck17 = document.getElementById('<%=rbExperienceLessThan1Year.ClientID %>');
                var Ck18 = document.getElementById('<%=rbExperience1to2years.ClientID %>');
                var Ck19 = document.getElementById('<%=rbExperience3to5years.ClientID %>');
                var Ck20 = document.getElementById('<%=rbExperienceMoreThan5years.ClientID %>');


                if (Ck1.checked == true || Ck2.checked == true || Ck3.checked == true || Ck4.checked == true) { } else { ErrorMessage += "Please fill Currency’s trading experience?\n"; }
                if (Ck5.checked == true || Ck6.checked == true || Ck7.checked == true || Ck8.checked == true) { } else { ErrorMessage += "Please fill experience?\n"; }
                if (Ck9.checked == true || Ck10.checked == true || Ck11.checked == true || Ck12.checked == true) { } else { ErrorMessage += "Please fill  CDF/Commodities trading experience? \n"; }
                if (Ck13.checked == true || Ck14.checked == true || Ck15.checked == true || Ck16.checked == true) { } else { ErrorMessage += "Please fill Futures trading experience\n"; }
                if (Ck17.checked == true || Ck18.checked == true || Ck19.checked == true || Ck20.checked == true) { } else { ErrorMessage += "Please fill Securities trading experience?\n"; }

                if (ErrorMessage.length != 0) {
                    alert(ErrorMessage);
                   //alert(ErrorMessage1);
                    return false;
                }

No comments:

Post a Comment