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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:34:52+00:00 2026-06-09T03:34:52+00:00

In the jQuery Validate docs it shows an example of using a remote validation

  • 0

In the jQuery Validate docs it shows an example of using a remote validation call to pass additional values to server side validation script/resource:

http://docs.jquery.com/Plugins/Validation/Methods/remote#code

Here’s the sample code:

$("#myform").validate({
  rules: {
    email: {
      required: true,
      email: true,
      remote: {
        url: "check-email.php",
        type: "post",
        data: {
          username: function() {
            return $("#username").val();
          }
        }
      }
    }
  }
});

Why do I need to use a function to set the username data parameter?:

username: function() {
  return $("#username").val();
}

rather than just:

username: $("#username").val()

I’ve tried both methods and sure enough the second method doesn’t assign username: a value.

I did set a breakpoint in the jQuery Validate code in the remote method function:

remote: function(value, element, param) {
    ...
}

to try and understand what is happening here, but I am really none-the-wiser.

  • 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-09T03:34:53+00:00Added an answer on June 9, 2026 at 3:34 am

    jQuery.fn.validate(config) is used to set up the validation rules, not actually perform validation. The entire {rules: /* */ } object is evaluated exactly when that happens.


    If you include

    $('#username').val()
    

    in the rules object, that expression will be evaluated immediately and the element’s value at that moment will be saved.


    If you instead pass

    function() { 
      return $('#username').val(); 
    }
    

    as the value, this function will be evaluated when the remote validator is invoked and the AJAX call is made, when jQuery.param flattens the data property into a string.

    Note that this validator merges its entire config object into every AJAX call it makes, so all other options acceptable in the normal ajax settings object can be set this way, not just data.

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

Sidebar

Related Questions

I am using jQuery validate for client side validation and I want to ignore
Using jquery validation: http://docs.jquery.com/Plugins/Validation I am also validating each field on blur: //validate each
I am using jquery form validation plugin http://docs.jquery.com/Plugins/Validation/validate How can I set a callback
I am using the jquery validate function and plugin located here. http://docs.jquery.com/Plugins/Validation I am
The following script using jQuery validation plugin - http://docs.jquery.com/Plugins/Validation - is preventing the form
I'm trying to use jquery validate. Following the example: http://docs.jquery.com/Plugins/Validation works great and I'd
i'm using jQuery validate() plugin to validate a form. it does the validation but
I use the JQuery Validation plugin to validate a form ( http://docs.jquery.com/Plugins/Validation/ ) For
I'm using jQuery validate plugin, and when I met the following script, i recognize,
I'm trying to use 'errorPlacement' from jQuery Validation DOCS : $(#myform).validate({ errorPlacement: function(error, element)

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.