Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 453963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:13:25+00:00 2026-05-12T22:13:25+00:00

HI, I am trying to validate a radio button form that has an unknown

  • 0

HI,
I am trying to validate a radio button form that has an unknown amount of radio groups.

So far I have this:

var object = $(".radio:checked");
var length = $('#numq').val();
if(object.length==length) {
    return true;
} else {    
    var unchecked = $(".radio:not(:checked)").empty();
    var q = "";
    unchecked.each(function(){
        q = q+$(this).parent("div").parent("li").children("div.question").children("b").text()+(",");
    });
    alert("Please answer question "+q);
    return false;
}

Which will check if all groups are checked fine… but when it comes to finding out the actual box that has been missed out, I’m having issues.

The markup for my radio buttons (php) is below:

<div class="question"><b><?=$qnum?></b><span><?=$row['question']?></span></div>

<div class="a1 answer">
    <input type="radio" class="radio" name="<?=$row['id']?>" value="1">
    <label><?=$row['answer1']?></label>
</div>

<div class="a2 answer">
    <input type="radio" class="radio" name="<?=$row['id']?>" value="2">
    <label><?=$row['answer2']?></label>
</div>

<div class="a3 answer">
    <input type="radio" class="radio" name="<?=$row['id']?>" value="3">
    <label><?=$row['answer3']?></label>
</div>

<div class="a4 answer">
    <input type="radio" class="radio" name="<?=$row['id']?>" value="4">
    <label><?=$row['answer4']?></label>
</div>

Any ideas?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:13:25+00:00Added an answer on May 12, 2026 at 10:13 pm

    In your loop where radio are generated, add a variable to count them, put total count in a hidden field, then from script read the value of this hidden field using getelementbyid and run the loop for as much time as this total and validate accordingly.

    This way, you know total number of them and validation process becomes easier then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use YUI to validate a radio button group on form submit
I have a group of radio buttons that I'm trying to validate with a
I'm trying to get jQuery validate to work with my radio button form. However,
I am trying to validate a dollar amount using a regex: ^[0-9]+\.[0-9]{2}$ This works
I am trying to validate a form, such that if IP of user (
I'm trying to validate a drivers license for a form that i am making.
I'm trying to validate that my custom Java object is serialized/de-serialized properly, and I
I'm trying to use the Jquery validation plugin to validate my form. I have
I'm trying validate an X.509 certificate received over a network. I have understood that
I'm trying to validate that a submitted URL doesn't already exist in the database.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.