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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:29:14+00:00 2026-05-29T05:29:14+00:00

I have a problem with my application which is here . Please follow steps

  • 0

I have a problem with my application which is here. Please follow steps below:

  1. When you open the application, click on “Open Grid” and select option 4. Buttons A, B, C and D will appear below.

  2. In the Number of Answers textbox, type in the number 1. Then click on 1 button out of A, B, C or D (The button selected will turn green). When you have done that then click on the “Add Question” button twice.

  3. As you can see the details you have entered on top will be dispayed in 2 new rows underneath. In the first new row you have added, in the textbox under the “Number of Answers” column, change the number 1 to 0 and in the second row change the number of Answers textbox from 1 to 2. Now click on the “Submit Details” button below.

An alert should appear which states “you have selected less answers than the required amount”. and it also states “you have selected more answers than the required amount”. This is correct as in the first row, there is one answer selected but in the textbox it states you want 0 number of answers, and in second row there is one answer selected but in textbox it states you wanted 2 answers.

My Question:

What my question is though that except showing both messages in an alert on both rows, what I want is that it will show an alert showing errors in the first row first. After the user has sorted the error in the first row, then if there is an error in second row then when the user clicks on the “Submit Details” button again, then show an alert displaying message of error in second row.

I want the alert to be displayed like this for first row for example:

Please fix error in question 1:
“you have selected less answers than the required amount”.

For the alert for the second row I want this:

Please fix error in question 2:
“you have selected more answers than the required amount”.

Below is the relevant validation code (I believe the problem is the var context as I think the variable is wrong but I am not sure):

  function validation() {

        alertValidation= "";
            // Note, this is just so it's declared...

            $(".numberAnswerTxtRow").each(function() {
  var currenttotal = $(this).closest('.optionAndAnswer').find('.answerBtnsOn') .length;     

            if (!this.value) {
                alertValidation += "\nPlease Enter in the Number of Answers you Require for this question\n";
            }
        else if (currenttotal > $(this).val()){
            alertValidation += "\nYou have selected more answers than the required amount\n";
        }

        else if (currenttotal < $(this).val()) {
            alertValidation += "\nYou have selected less answers than the required amount\n";
        }
        });


        if(alertValidation != "")
        {
            alert(alertValidation);
            return false;
        }

Hopefully this makes sense, if it doesn’t then please comment to me.

Below is an edit to the validation() function with textarea validation:

 function validation() {

$(".textAreaQuestion").each(function() {

   alertValidation= ""; 

        if (!this.value || this.value.length < 5) {
            alertValidation += "\nYou have not entered a valid Question\n";
        }

    if(alertValidation != "") 
    { 
        alert(alertValidation); 
        return false; 
    } 

    });

$(".numberAnswerTxtRow").each(function() { 

    alertValidation= ""; 

    var currenttotal = $(this).closest('.optionAndAnswer').find('.answerBtnsOn') .length;      

    if (!this.value) { 
            alertValidation += "\nPlease Enter in the Number of Answers you Require for this question\n"; 
    } 
    else if (currenttotal > $(this).val()){ 
        alertValidation += "\nYou have selected more answers than the required amount\n"; 
    } 

    else if (currenttotal < $(this).val()) { 
        alertValidation += "\nYou have selected less answers than the required amount\n"; 
    } 

    if(alertValidation != "") 
    { 
        alert(alertValidation); 
        return false; 
    } 
}); 

     return true;
}
  • 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-29T05:29:14+00:00Added an answer on May 29, 2026 at 5:29 am

    You should stop the each loop by returning false once if any error condition is valid. Try this.

      function validation() {
    
            var alertValidation = "";
            // Note, this is just so it's declared...
    
            $(".numberAnswerTxtRow").each(function() {
                var currenttotal = $(this)
                                   .closest('.optionAndAnswer')
                                   .find('.answerBtnsOn').length;     
    
                if (!this.value) {
                    alertValidation += "\nPlease Enter in the Number of Answers you Require for this question\n";
                }
                else if (currenttotal > $(this).val()){
                     alertValidation += "\nYou have selected more answers than the required amount\n";
                }
    
                else if (currenttotal < $(this).val()) {
                     alertValidation += "\nYou have selected less answers than the required amount\n";
                }
                if(alertValidation != ""){
                    return false;//Stop the each loop
                }
            });
    
    
            if(alertValidation != "")
            {
                alert(alertValidation);
                return false;
            }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with my application which is here . Please follow steps
I have an application you can access here When you open the app, please
I have a problem with an application which uses the same stored procedure over
I have a problem with a little .Net web application which uses the Amazon
I have a problem, which is not easily described. I'm writing a web application
The problem: we have one application that has a portion which is used by
I have made a swings application but there is one problem in that which
I have this .bat script which I use to maven package my application. Problem
I have WinForm application which is almost ready to go for production and here
I have a jsfiddle application which you can access here . Now when you

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.