how to display message in alert if total marks does not equal 0
<p>I have an application <a href="http://helios.hud.ac.uk/u0867587/testing/Testpage.php" rel="nofollow">here</a>. When you open the application then please type in a number in the textbox and click on the "Add question" button. This will add a new row and it will do a calculation between total session marks remaining and then number you have entered.</p>

<p>What I want to know if that how do I display in my alert that that if ('#total-weight') does not equal 0, then display an alert stating:</p>

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

You have '' marks remaining  //this is if total session marks is above 0

OR

You need to remove '' marks  // this is if total session marks is below 0
</code></pre>

<p>Below is code which does the subtraction:</p>

<pre><code>var totalmarks = '10';

$(document).ready(function()

{

$('#total-weight').html(totalmarks);

    $(document).on('change', '#qandatbl td.weight input', calculateTotal);

});

function calculateTotal()
{
   var totalweight = totalmarks;
   $("#qandatbl td.weight input").each(function (i, elm){
        totalweight = totalweight - Number($(elm).val(), 10);
    });

    $("#total-weight").text(totalweight);
}
</code></pre>

<p>Below is the validation code where all the other alerts appear:</p>

<pre><code>function validation() {

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

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

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

<p>I only want this alert to appear when all the rows do not contain any errors. Can this be done? </p>
