Why does my function get called when it's not supposed to?
<p>I have 2 java script functions. If the first one returns true, the 2nd one is not to be executed. If the first one returns false, only then the second function to be executed.
So I am trying to achieve this with the following code:</p>

<pre><code>  &lt;script type="text/javascript" language="javascript"&gt;   

     function needsForcedReset() {

           if($("#showMessage").text().length &gt; 0) {
               return true;
           }
           return false;
     }

     function sendAlert() {
         //Sends an alert;
         alert('oh oh');
     }

     $(document).ready(function() {
        alert('in doc ready');
      if (needsForcedReset()) {
        alert('Need force reset, no check for alerts');
        return;
      }
      else {
        sendAlert();
     }

  });



  &lt;/script&gt;
</code></pre>

<p>What I am seeing though, is that the sendAlert is being called regardless of what the needsForcedReset function return. How do I make it work?</p>

<p><b>Edit: the showMessage is a div element </b></p>
