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 6836599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:22:29+00:00 2026-05-26T23:22:29+00:00

So if both validations work seperatley (if I just put radio buttons validation in

  • 0

So if both validations work seperatley (if I just put radio buttons validation in the function without the spinner validation then radio buttons validation works and same vise versa), how come when I put both validations in the function, the top validation which is the radio validation works but the bottom validation which is the spinner validation does not display a message when it is suppose to?

Code is below:

        <head>
                <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
                <title>Create a Session</title>
                        <script type="text/javascript">

    function validation() {
                    var errMsgO = document.getElementById("radioAlert");
                    var btnRadioO = document.getElementsByName("sessionNo");               
                    var isbtnRadioChecked = false;
                    var errQuesMsgO = document.getElementById("numberAlert");
                    var questionNumberO = document.getElementsByName("txtQuestion");

                    for(i=0; i < btnRadioO.length; i++){
                        if(btnRadioO[i].checked){
                            isbtnRadioChecked = true;
                        }
                    }

                    if(!isbtnRadioChecked) {
                       errMsgO.innerHTML = "Please Select the Number of Sessions you Require";
                    } else {
                        errMsgO.innerHTML = "";
                    }
                    return false; 



        if(questionNumberO[0].value == 0){
            errQuesMsgO.innerHTML = "Please Set the Number of Questions";
        } else {
            errQuesMsgO.innerHTML = "";
        }
           return false; 
                }    
</script>
        </head>
        <body>
        <form action="create_session.php" method="post" name="sessionform">
    <table>
              <tr>
              <th>2: Number of Sessions :</th>
              <td class="sessionNo"><input type="radio" name="sessionNo" value="1" />1</td>
              <td class="sessionNo"><input type="radio" name="sessionNo" value="2" />2</td>
              <td class="sessionNo"><input type="radio" name="sessionNo" value="3" />3</td>
              <td class="sessionNo"><input type="radio" name="sessionNo" value="4" />4</td>
              <td class="sessionNo"><input type="radio" name="sessionNo" value="5" />5</td>
              </tr>
              </table>
              <div id="radioAlert"></div>
        <table>
                    <tr>
                    <th>Number of Questions:</th>
                        <td class="spinner"><textarea class="spinnerQuestion" name="txtQuestion" id="txtQuestion" cols="2" rows="1"></textarea></td>
                        <td><button class="scrollBtn" id="btnQuestionUp"><img src="Images/black_uppointing_triangle.png" alt="Increase" /></button>
                        <button class="scrollBtn" id="btnQuestionDown"><img src="Images/black_downpointing_triangle.png" alt="Decrease" /></button></td>
                        </tr>
                        </table>
                        <div id="numberAlert"></div>
                        <p><input class="questionBtn" type="button" value="Prepare Questions" name="prequestion" onClick="validation()" /></p>      <!-- Prepare Questions here-->

                </form>
        </body>
  • 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-26T23:22:29+00:00Added an answer on May 26, 2026 at 11:22 pm

    The one mistake I could spot is the line if(questionNumberO == 0){ (besides you have not closed your <script> element with </script>).

    The correct way is:

    if(questionNumberO[0].value == 0){
    

    Why:

    getElementsByName() will return a collection of elements with the specified name attribute. If you know there is only one, you can ask for the first one ([0]).

    The value property stores the current value of an input element. See HTMLInputElement on MDN.

    Update: I have created a working jsFiddle Demo for you.

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

Sidebar

Related Questions

Server side validation works great but client side will not work on some fields.
Which XML validation tools can you recommend for both performance and accuracy, each of
<td align=left valign=top> Generates no validation errors, does it mean both are valid?
Both DataSource and DataSourceID are defined on 'grdCommunication'. Remove one definition. I just got
For the ASP.NET validator controls, I want to use both client-side validation for the
I am developing a web application which needs to work with both IE7 and
I'm having one heck of a time getting this validation to work. I'm using
validation work i use ($this->Form->input) <?php echo $this->Form->input('Car', array('type'=>'textarea','label'=>false, 'cols'=>'23', 'rows'=>'4'));?> and if i
Does anyone know how the validation will work with V1? I'm at the crossroads,
I am writing my own form validation plugin. I am making to work with

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.