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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:17:24+00:00 2026-05-29T07:17:24+00:00

In this jsfiddle , please follow the steps below: 1: When you open fiddle

  • 0

In this jsfiddle, please follow the steps below:

1: When you open fiddle click on the “Add Question” button twice, this will add 2 rows underneath.

2: Click on the “Submit details” button and it will come up with this error:

You have errors on Question Number: 2

You have not entered a valid Question

Please Enter in the Number of Answers you Require for this question

Please enter in a figure for Number of Marks for this Question

You have not entered a valid Question

Please Enter in the Number of Answers you Require for this question

Please enter in a figure for Number of Marks for this Question

This is incorrect, the alert above displays all of the errors and the incorrect question number. What should happen is that if there are errors in multiple rows, then it should display the number of the first row which contains errors and display those errors in the alert. The alert should display this:

You have errors on Question Number: 1

You have not entered a valid Question

Please Enter in the Number of Answers you Require for this question

Please enter in a figure for Number of Marks for this Question

Also another problem is that if in the second row you fill in the textarea and textboxes, it displays this alert below:

You have errors on Question Number: 2

You have not entered a valid Question

Please Enter in the Number of Answers you Require for this question

Please enter in a figure for Number of Marks for this Question

The above alert is incorrect as it is stating the wrong question number where the errors are. The question number should be number 1, not number 2. So how can this be fixed as well.

Below is the code of the validation() function where the alerts are controlled:

function validation() {

    var _qid = "";
    var _msg = "";

    alertValidation = "";
    // Note, this is just so it's declared...
    $("tr.optionAndAnswer").each(function() {


        _qid = $("td.qid",this).text();
        _msg = "You have errors on Question Number: " + _qid + "\n";

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



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

            if (alertValidation != "") {
                return false; //Stop the each loop 
            }
        });

        $(".numberAnswerTxtRow",this).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";
            }

            if (alertValidation != "") {
                return false; //Stop the each loop 
            }

        });

        $(".txtWeightRow",this).each(function() {


            if (!this.value) {
                alertValidation += "\nPlease enter in a figure for Number of Marks for this Question\n";
            }

            if (alertValidation != "") {
                return false; //Stop the each loop 
            }
        });
    });

    if (alertValidation != "") {
        alert(_msg + 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-29T07:17:24+00:00Added an answer on May 29, 2026 at 7:17 am

    You have to check if any error is already found in the outer loop ($("tr.optionAndAnswer").each()) and stop it by returning false.

    Add this in the outer each loop and declare alertValidation as var alertValidation otherwise it will be in the global scope.

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

    I have fixed it in your fiddle demo take a look.

    http://jsfiddle.net/ShankarSangoli/euL5e/1/

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

Sidebar

Related Questions

Please follow these steps in the jsfiddle to understand my question Click on open
Please see this: http://jsfiddle.net/uNbYu/1/ If you click submit, the button doesn't do anything, but
This question was asked here but the issue wasn't resolved. Please see this jsfiddle
Please see this jsFiddle . Note that the click event works just fine (try
Please see this http://jsfiddle.net/yv8uw/1/ When you click View all Comments the box opens up
This is a difficult and open-ended question I know, but I thought I'd throw
Please see this jsFiddle: https://jsfiddle.net/Wmq6f/ I have a textarea that has a background image,
Please check out this http://jsfiddle.net/karthik64/JHVDn/1/ . Well I believe you got where I am
Well Im stucked at this point.please take a look at this http://jsfiddle.net/karthik64/5jhgF/3/ Okay first
Can someone please help me out with this? I'm using jquery-1.4.2. http://jsfiddle.net/Ymkpb/ Thank 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.