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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:06:30+00:00 2026-05-28T05:06:30+00:00

I have made this function, that seems to work fine, but it return #

  • 0

I have made this function, that seems to work fine, but it return “#” insted of wainting for the AJAX. I have tried to remove the return call, with out look.

It need to wait until the AJAX is finish before return. The JSP is working fine.

What is wrong?

jQuery.validator.addMethod("knidExist", function(value, element) {
    var valid = "#";
      $.ajax({
          async: false,
          type: "POST",
          url: "USER.jsp",
          data: "knid="+value,
          dataType: "html",
          success: function(msg) {
              // if the user exists, it returns a string "true"
              if($.trim(msg) != "true") {
                 //return false;
                 valid = false;  // already exists
              } else {
                 //return true;
                 valid = true;      // username is free to use
              }
          }  
     });
    return valid;
}, 'This USER does not exist');
  • 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-28T05:06:30+00:00Added an answer on May 28, 2026 at 5:06 am

    I found a method by my self. Almost a complete copy from the remote method but with static message and url.
    Hope i can help some one.

    jQuery.validator.addMethod("userExist", function(value, element, param) {
    if ( this.optional(element) )
        return "dependency-mismatch";
    
    var previous = this.previousValue(element);
    if (!this.settings.messages[element.name] )
        this.settings.messages[element.name] = {};
    previous.originalMessage = this.settings.messages[element.name].remote;
    this.settings.messages[element.name].remote = previous.message;
    
    param = typeof param == "string" && {url:param} || param;
    
    if ( this.pending[element.name] ) {
        return "pending";
    }
    if ( previous.old === value ) {
        return previous.valid;
    }
    
    previous.old = value;
    var validator = this;
    this.startRequest(element);
    var data = {};
    data["**user**"] = value;
    $.ajax($.extend(true, {
        url: "validation.jsp",
        mode: "abort",
        dataType: "json",
        data: data,
        success: function(response) {
            validator.settings.messages[element.name].remote = "**This user do not exist"**;
            var valid = response === true;
            if ( valid ) {
                var submitted = validator.formSubmitted;
                validator.prepareElement(element);
                validator.formSubmitted = submitted;
                validator.successList.push(element);
                validator.showErrors();
            } else {
                var errors = {};
                var message = response || validator.defaultMessage( element, "remote" );
                errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
                validator.showErrors(errors);
            }
            previous.valid = valid;
            validator.stopRequest(element, valid);
        }
    }, param));
    return "pending";
    }, "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi have made this function which is made to replicate an error that I
This seems fairly trivial but I can't seem to work it out I have
I have a problem with a javascript set of functions that I made. This
I have made some progress with the DataList and UserControl this morning but I
Hi I made this site a while ago in my table days but have
This is a C++ class that I have made with n number of pointers.
I have a program i frequently use that is made with .NET. This program
OK, I was just fooling around in my spare time and have made this
This is my first winform app in .NET... I have made a couple of
Since I'm sure many people have different standard, I've made this post a community

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.