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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:06:14+00:00 2026-05-18T11:06:14+00:00

I’m trying to remote validate a field by looking at two different fields. The

  • 0

I’m trying to remote validate a field by looking at two different fields. The issue is, in all the examples I see on how to do remote validate sending additional data, they’re using the id of the other field that is being processed. So the example on the jQuery validate API page for remote() uses “#username” and sends that in addition to the email field.

My page is odd, and has multiple forms that are the same, and the number of forms on the page is variable, so I can’t have a unique id for each field. Is there a way to find out which field or form is being validated/making the remote call? I tried something like the following, because I thought that $(this) would have been the text box being validated, or the individual form being validated, but that doesn’t appear to be the case.

number: {
                  required: true,
                  number: true,
                  remote: {
                    url: "confirm.php",
                    data: {
                        toy: function() {
                            return $('select[name="toy"]:selected',this).val();
                        }
                    }
                  }
          }

Thanks,
Jared

Edit: I ended up figuring out a way to get it working. The advice to pass the form along gave me the idea.

Since I had multiple forms on the page, I was using
$(‘form’).each(function() {$(this).validate({….})});

So I just saved a reference to the current form with var form = $(this) before the validate call, and then within the example I gave earlier I only had to make a small change:

data: {
    toy: function() {
        return $('select[name="toy"]',form).val();
    }
}

And now each field knows which form it belongs to!

  • 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-18T11:06:15+00:00Added an answer on May 18, 2026 at 11:06 am

    You could assign a unique formId to each of the forms, and whenever the form is submitted, you could submit the formId alongwith the other info from the form in order to identify which form is being submitted?

    For example, in the html code of your form, you could do something like this:

    Form # 1: (with form id as 1)

    <form id="form_1">
    Name: <input type='text' id='name_1'> <br>
    Address: <input type='text' id='address_1'> <br> 
    <input type='button' value='Submit' onclick='validate(1);'>
    </form>
    

    Form # 2: (with form id as 2)

    <form id="form_2">
    Name: <input type='text' id='name_2'> <br>
    Address: <input type='text' id='address_2'> <br> 
    <input type='button' value='Submit' onclick='validate(2);'>
    </form>
    

    In the javascript, something like this:

    function validate(formId)
    {
       var data = {};
       //Example data that is to be submitted for validation:
       data.name = $("#name_" + formId).val();
       data.address = $("#address_" + formId).val();
       //.. and so on
       data.formId = formId;
    
       $.post('http://example.com/confirm.php', data, function(result)
         {
           //process the return of the remote validation here, 
           //found in the variable: result
         }
       );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.