Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're comparing Strings when you do <code>$("[class*=q" + i + "_mark]").text() &lt; '0'</code>, so try the != (Not Equal) operator versus the &lt; (Less Than). Example:</p> <pre><code> $("[class*='q'").each(function (i) { var marks = parseInt($("[class*=q" + i + "_mark]").text()); _qid = $(".q" + i + "_ans_org").text(); _msg = "You have errors on Question Number: " + _qid + "\n"; if (!this.value) { alertValidation += "\n\u2022 You have not entered in a value for all the Indivdiaul Marks textbox\n"; } if ($("[class*=q" + i + "_mark]").text() != '0') { alertValidation = "Your Total Marks Remaining does not equal 0 \n\n\u2022 You Need To Remove " + Math.abs(marks) + " Marks"; } else { alertValidation = "Your Total Marks Remaining does not equal 0 \n\n\u2022 You Have " + marks + " Marks Remaining"; } if (alertValidation != "") { return false; //Stop the each loop } }); </code></pre> <p>Otherwise use your variable:</p> <pre><code> $("[class*='q'").each(function (i) { var marks = parseInt($("[class*=q" + i + "_mark]").text()); _qid = $(".q" + i + "_ans_org").text(); _msg = "You have errors on Question Number: " + _qid + "\n"; if (!this.value) { alertValidation += "\n\u2022 You have not entered in a value for all the Indivdiaul Marks textbox\n"; } if (marks &lt; 0) { alertValidation = "Your Total Marks Remaining does not equal 0 \n\n\u2022 You Need To Remove " + Math.abs(marks) + " Marks"; } else if (marks &gt; 0) { alertValidation = "Your Total Marks Remaining does not equal 0 \n\n\u2022 You Have " + marks + " Marks Remaining"; } if (alertValidation != "") { return false; //Stop the each loop } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload