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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:52:36+00:00 2026-05-27T04:52:36+00:00

I am dealing with a webpage that has multiple forms..some basic HTML forms and

  • 0

I am dealing with a webpage that has multiple forms..some basic HTML forms and some AJAX forms. I have a created validation for inputs, let me give an example…if an input has a class=”required” whenever a submit button is pressed if any required classes are empty then the form doesnt submit. Which works great…until you have multiple forms with required fields that dont apply to the section your submitting.

I am able to find the closest form $(this).closest(“form”) and it gets me the form element properly, I then need to be able to loop only through the children of that form. I have tried: .children(‘:input’), .find(‘input’) and honestly to many to list.

Here is the code for when a button is selected

$('#formSubmit').click(function (e) {
        var submit = true;
        var form = $(this).closest("form");
        var formID = $(form).attr("id");
        e.preventDefault();

        $(form).children(":input").each(function () {
            if ($('#ERROR').length > 0) {
                submit = false;
                alert("Please fix errors to continue");
            }
            $('.required').each(function () {
                if ($(this).val() == "" || $(this).val() == undefined) {
                    submit = false;
                    $(this).css({ 'background-color': '#fef236' });
                }
            });
        });
        if (submit == true) {
            this.form.submit();
        }
    }); //End of #formSubmit

Also of interest I have started creating forms with ids that are GUID’s so they will be unique and allow me to target things without any issues, just wanted to throw that out there if it can help lead to a solution

I appreciate any help =)

  • 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-27T04:52:37+00:00Added an answer on May 27, 2026 at 4:52 am

    $(this).closest("form").find(":input") is a correct way to find all the inputs. I think the problem lies in $('.required'). That call starts the search again from the global level, thus finding inputs from all forms on the page.

    I don’t see the need to do .find(":input") in the first place. Just get the required fields with form.find(".required") and loop through those.

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

Sidebar

Related Questions

I'm dealing with a LAMP web server. I have forms that users use to
I'm dealing with data that has been sampled using Java HtmlUnit. The webpage used
Dealing with an employee that went over my head
When dealing with a single file, I'm used to: /blah do some work n
I frequently have problems dealing with DataRows returned from SqlDataAdapters . When I try
I'm dealing with a MySQL table that defines the JobName column as UNIQUE. If
I am dealing with MySQL tables that are essentially results of raytracing simulations on
The table I'm dealing with it potentially larger than available memory (let's say 10GB)
When dealing with a flash application that will run in a browser, it's obvious
When dealing with websites with large amount of javascript, i see that these are

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.