Validation function with return value
<p>I have a common validation function <br></p>

<pre><code>function connect_and_update_destination() {
        var flag = true;
        // Validate IP
        if (!validate_ip_address()) {
            alert(protect.lang.enter_valid_ip);
            return;
        }

        if ($('#pjm_alias').val() === '') {
            $('#pjm_alias').focus();
            alert(protect.lang.enter_alias);
            return;
        }

        if ($('#pjm_auth_name').val() === '') {
            $('#pjm_auth_name').focus();
            alert(protect.lang.enter_auth_name);
            return;
        }

        if ($('#pjm_auth_password').val() === '') {
            $('#pjm_auth_password').focus();
            alert(protect.lang.enter_auth_pwd);
            return;
        }
        var ip = $('#pjm_ip1').val()+'.'+$('#pjm_ip2').val()+'.'+$('#pjm_ip3').val()+'.'+$('#pjm_ip4').val();
        return establish_connection(ip, $('#pjm_alias').val(), $('#pjm_auth_name').val(), $('#pjm_auth_password').val());
    }
</code></pre>

<p><br>
After successful validation it always return <strong>establish_connection()</strong>, My problem is that am calling this <strong>connect_and_update_destination()</strong> like this, <br></p>

<pre><code>function first_call(){
  connect_and_update_destination();
}
function second_call(){
  connect_and_update_destination();
}
</code></pre>

<p><br>
When first call i need to return after successful validation <strong>establish_connection()</strong>, But when ever i called its using second function [second_call()] it should not return <strong>establish_connection()</strong> insted of return <strong>establish_connection()</strong> i need to only return . But how can i do this, Means i dont want to enter establish_connection() when ever i call using <strong>second_call()</strong>. <br></p>

<p>Thanks in advance.</p>
