JavaScript function execution on onBlur event of textbox
<p>I wrote following :</p>

<pre><code>function loginName(txtLogin){
    var l = document.getElementById('txtLogin').value;
    &lt;?php
        $query = sprintf("Select * from register where LoginName='%s'",
                        mysql_real_escape_string(l));

        //$query =  "Select * from register where UserName=$Username and     Pwd=$Password";
        $result = mysql_query($query);
        if($result)
        {
            $num_rows =  mysql_num_rows($result);
        }
    ?&gt;
    if($num_rows &lt; 1)
    {
        return true;
    }
    else
    {
        return false;
    }
}
</code></pre>

<p>and call that function on onBlur event as below:</p>

<pre><code> $('#txtLogin').blur(function() {
      if(loginName('txtLogin'))
      {
          //alert('Email is valid');
      }
      else
      {
          alert('Type another login name.');
      }
   });
</code></pre>

<p>But its not showing error when I enter same login name as exist in database.please help.</p>
