Javascript code execution going inside if condition even though condition is false
<p>This is one of the weirdest behavior I have seen. Following is the js code snippet:</p>

<pre><code>else if ($("*[id$=ddlDefaultPurpose]").val() == 2) {
    if ($("*[id$=ddlJobCategory]").val() == -1) {
        ShowMessageStrip(errorJobCategory);
        formIsValid = false;
    }
    //else if (!TryParseSalaryOffered($("*[id$=txtCurrentSalary]").val())) {
    //    ShowMessageStrip(errorCurrentSalary);
    //    formIsValid = false;
    //}
}
</code></pre>

<p>Now when the code executes, <code>$("*[id$=ddlJobCategory]").val()</code> is not equal to -1. And this can be seen clearly in Firebug. Now what happens is that the after the evaluating the condition, the code should come out, but instead it goes to the line <code>formIsValid = false</code>. It skips the <code>ShowMessageStrip(errorJobCategory)</code>. </p>

<p>Why could this be happening?</p>
