Function is returning false even the condition is true why?
<pre><code>function checkform(for1)
{ 
   var result=checkform1(for1);
   alert(result);
}
function checkform1(form)
{
    var valid=false;
    var val1 = document.getElementById('security_code').value;
    $.get(url, function(data) {
        if(data.toString()==val1.toString())
        {
            var elem = document.getElementById("captchaerr");
            elem.style.visibility = 'hidden';
            valid=true;
        }
        else
        {
            var elem = document.getElementById("captchaerr");
            elem.style.visibility = 'visible';
            valid=false;
        }           
    }); 
    return valid;
}
</code></pre>

<p>result alert is always false even the condtion(data.toString()==val1.toString()) is true
how the control passes in this.
thnks..</p>
