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 3484852
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:50:13+00:00 2026-05-18T10:50:13+00:00

http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ Iam using this form plugin.where we can call Separate function inorder to do

  • 0

http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/ Iam using this form plugin.where we can call Separate function inorder to do validation

    <input type="text" id  ="empno " class="validate['required',FuncCall[empnos]]">

“Funccall[empnos]” which is File Jquery-validation-en.js will call separate JS function called empvalidate()

"empnos" : {
        "nname":"empvalidate()",
        "alertText":"* This EMP NO  is not there "      
},  
function empvalidate(){
                var empno = $("#empno").val();
                if(empno!=''){
                    $.ajaxSetup ({cache: false});
                    $.getJSON("emp.php",{'param1' : $("#param1").val(),'empno' :$("#empno").val()},
                        function (data){
                              if(data['status']==="true"){
                              exists="true";
                             }else{
                             exists="false";
                             }
                    });
                }
                return exists;
    }

From The above function iam not able to return true or false as it has anoymous function.
How can i return true when the status is true and vice versa.It is always returning me false

  • 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-05-18T10:50:13+00:00Added an answer on May 18, 2026 at 10:50 am

    Ajax method getJSON performs asynchronously, so your method returns ‘exists’ before it requested the server for a return value.
    So you need to make your ajax request as async = false, like this:

    UPD: Okay, see the full version of your function:

    function empvalidate() {
      var exists = false;             // default return value is false
      var empno = $("#empno").val();
      if (empno != '') {
        $.ajax({
          url: "emp.php",
          async: false,
          dataType: "json",
          data: {'param1': $("#param1").val(), 'empno': $("#empno").val()},
          success: function (data) {
            exists = data.status;     // set status of existence to outer variable
          }
        });
      }
      return exists;                  // return actual value
    }
    

    Take care, I did not test the code above, so you need to understand the reason of each line of the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This web page http://www.w3schools.com/ASP/prop_sessionid.asp states that a session ID is generated on the ServerSide.
http://www.codeplex.com/IIRF/Thread/List.aspx My webhost installed IIRF for me and I am convinced that they did
From http://www.jibbering.com/faq/faq_notes/closures.html : Note: ECMAScript defines an internal [[prototype]] property of the internal Object
I found this: http://www.evolt.org/failover-database-connection-with-php-mysql and similar examples. But is there a better way? I
MDI Bug http://www.dicu.com/pics/bug_mdi.jpg That's what I get when I try to automatically maximize MDI
In dopplr [ http://www.dopplr.com] there is an option to fill the city of travel
Seeing this: http://www.suckless.org/wiki.html . A wiki based on Mercurial. Are there any other non-code
From http://www.faqs.org/rfcs/rfc2822.html : CR and LF MUST only occur together as CRLF; they MUST
I decided to try http://www.screwturn.eu/ wiki as a code snippet storage utility. So far
I went to http://www.json.org/js.html and downloaded the json2.js, thinking i'd be fine, afterall that

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.