We help IT Professionals succeed at work.
Get Started

Validate multiple radiobuttonlist validation with error message each group

TonyReba
TonyReba asked
on
912 Views
Last Modified: 2012-05-09
I have this codes to validate a set of radiobutton list , list items controls in my questionarie., question is how can I extend it to validate all questions e.g.

radiobuttonlist2, radiobuttonlist3,.......  

and display which question was not not answered. ,,,,

thanks and look forward for assistance..
<script type = "text/javascript">

    function Validate() {

        var RB1 = document.getElementById("<%=RadioButtonList1.ClientID%>");

        var radio = RB1.getElementsByTagName("input");

        var isChecked = false;

        for (var i = 0; i < radio.length; i++) {

            if (radio[i].checked) {

                isChecked = true;
                break;

            }

        }

        if (!isChecked) {

            alert("Please select an option in each question");

        }

        return isChecked;

    }

</script>


Control:
 <asp:RadioButtonList ID="RadioButtonList1" repeatdirection="Vertical" runat="server">
                
                    <asp:ListItem Value="Yes"></asp:ListItem>
                    <asp:ListItem Value="No"></asp:ListItem>
                 </asp:RadioButtonList>

Open in new window

Comment
Watch Question
Top Expert 2013
Commented:
This problem has been solved!
Unlock 2 Answers and 12 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE