Alert should only appear after all table rows have no errors
<p>Below is my validation() function which controls some messages in an alert:</p>

<pre><code>function validation() {

    var marks = parseInt($("#total-weight").text());    
    var _qid = "";
    var _msg = "";

    var 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";

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


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

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


        if(alertValidation != ""){
            return false;
        }
    });
</code></pre>

<p>// SPLIT</p>

<pre><code>            if($("#total-weight").text() &lt; '0')
{
 alertValidation += "Your Total Session Marks Remaining does not equal 0 \n\n\u2022 You Need To Remove " + Math.abs(marks) +  " Marks";   
}

        else if($("#total-weight").text() &gt; '0')
{
 alertValidation += "Your Total Session Marks Remaining does not equal 0 \n\n\u2022 You Have " + marks +  " Marks Remaining";   
}

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

    return true;
}
</code></pre>

<p>I have included a //SPLIT comment in the function. The reason I have done this is because if you look at the  `$(".txtWeightRow",this).each(function() {, that goes into a table row so it has a question number (table row number) attached to that error. But below the split you see an if and else if statements, these statements don't deal with anything in a table row so it should not have a question number (table row number) attached in the alert.</p>

<p>Now lets say for eaxmple if you look at the condition below the //SPLIT that the #total-weight > 0, it displays this alert below:</p>

<pre><code>You have errors on Question Number: 1
Your Total Session Marks Remaining does not equal 0 

• You Have 5 Marks Remaining
</code></pre>

<p>The above is incorrect as it is not in a table row so it should not display a question number. The alert instead should display this:</p>

<pre><code>Your Total Session Marks Remaining does not equal 0 

• You Have 5 Marks Remaining
</code></pre>

<p>Why is it displaying the question number and how can I get rid of "You have errors on Question Number: 1" from the alert?</p>

<p>Also the alert messages in the conditions below the //SPLIT should only appear after there is no errors in the all the table rows. If there is an error in any table row, then don't display the alert above, but if there is no error in any table row, then display the alert above if the condition to show the alert is met. So how can this be done?</p>
