Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8101763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:04:00+00:00 2026-06-05T23:04:00+00:00

I have a common validation function function connect_and_update_destination() { var flag = true; //

  • 0

I have a common validation function

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());
    }

After successful validation it always return establish_connection(), My problem is that am calling this connect_and_update_destination() like this,

function first_call(){
  connect_and_update_destination();
}
function second_call(){
  connect_and_update_destination();
}

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

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:04:02+00:00Added an answer on June 5, 2026 at 11:04 pm

    You could do something as simple as passing a variable.

    function connect_and_update_destination(establishConnection) {
    
     ...
    
     if(!establishConnection)
       return;
    
     return establish_connection(ip, $('#pjm_alias').val(), $('#pjm_auth_name').val(), $('#pjm_auth_password').val());
    }
    
    function first_call(){
      connect_and_update_destination(true);
    }
    function second_call(){
      connect_and_update_destination(false);
    }
    

    For a more generic solution, you could pass a callback:

    function connect_and_update_destination(callback) {
    
        ...
    
        if(typeof callback === 'function') {
           return callback(ip);
        }
    
        return;
    }
    
    function first_call() {
        var result = connect_and_update_destination(function(ip) {
           return establish_connection(ip, $('#pjm_alias').val(), $('#pjm_auth_name').val(), $('#pjm_auth_password').val());
        });
    }
    
    function second_call() {
        connect_and_update_destination();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im looking to have a common parent function like so void main (param 1,
I made common validation message (You have errors on page) using invalidHandler option. Now
I have to perform a common validation task on each control on a lightswitch
This is a slightly original variation on a common problem. I have a fairly
I have common functionality that I need to access from all screens of my
I have this common issue of 'new line' in php-csv which is making me
I have a common comms library that i have written to communicate with our
I have a common script which Im including in my PHPcron files and the
I have a common resource, which I want 1 and only 1 instance of
I have a common problem that I never know how to solve with CSS:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.