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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:30:15+00:00 2026-05-28T23:30:15+00:00

Below is my validation function: function validation() { alertValidation= ; // Note, this is

  • 0

Below is my validation function:

function validation() {


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

    $(".textAreaQuestion").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").each(function() {

        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").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 
            } 
    });

What the code above does is that it displays an alert for each row if there are any errros in the row.

Example:

If in a table row the user has left .textAreaQuestion, .numberAnswerTxtRow and .textWeightRow all empty, then in the alert it will display all of the related messages in one alert like below:

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

Now each table row has its own question number (table row number). So what I want to know is that how can I include the question number in the alert so that it states which rows the alert messages are refering to? If it was like the example above I want the alert to be displayed like below:

You have errors on question number: 1 // how do I display this line in the alert

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

Below is the code on how the question number is added into each table row:

var qnum = 1;

function insertQuestion(form) {  

    var $tbody = $('#qandatbl > tbody'); 
    var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
    var $qid = $("<td class='qid'>" + qnum + "</td>");

$tr.append($qid);
$tbody.append($tr); 

   $(form).find('.numberOfQuestions').val(qnum);

    ++qnum;
    $("#questionNum").text(qnum);

}

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-28T23:30:16+00:00Added an answer on May 28, 2026 at 11:30 pm

    Well since you added the class qid to the td containing the questionnumber you should be able to access it via $('td.qid').html(). This gives you the innerhtml of the td with the class qid check here for more info.

    EDIT:
    On second thought $('td.qid').text() might be better.

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

Sidebar

Related Questions

Below is my validation() function which controls some messages in an alert: function validation()
I am using this IP Validation Function that I came across while browsing, it
I have a form validation function that loops through the form elements checking for
I have a jqGrid (pared-down example below) where I need rather complicated validation to
I am using jQuery Validate Plugin found from below URL http://bassistance.de/jquery-plugins/jquery-plugin-validation/ I just wanted
my form validation does not firing...if i try to submit this form without entering
I have code like below to perform some conditional validation on fields in my
I have some code for validating date below: function validateForm() { var errFound =
I have the following code to perform validation of SubmitForm shown below .when i
Below code makes form to be submitted without html5 validation... $j(document).on(click, #client_entry_add, function(event){ ajax_submit();});

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.