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

  • Home
  • SEARCH
  • 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 8877409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:27:43+00:00 2026-06-14T19:27:43+00:00

I have 2 forms in 1 page form.php . In 1st form I have

  • 0

I have 2 forms in 1 page form.php. In 1st form I have 1 input field and 1 textfield. And second form I have an upload image button, that I use to upload without redirecting so onchange I am submitting that form.

But if user has not selected any image the final form should not submit.

Here is my code:

$("#storyform").validate({
  rules: {
    story: {
      required: true,
      maxlength: 250
    },
    place: "required"


  },
  messages: {
    story: {
      required: "Please write your story",
      maxlength: $.format("At Max {0} characters !")
    },

    place: "Please write your place"

  },
  errorElement: "span",
  wrapper: "span" // a wrapper around the error message

});
  • 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-14T19:27:44+00:00Added an answer on June 14, 2026 at 7:27 pm

    Initialize .validate() on each form separately. Then just test to see if the first form is valid using .valid() within the submitHandler on the second form.

    $(document).ready(function(){
    
        $("#firstForm").validate({  // initialize form validation on form 1
            // rules & other options
        });
    
        $("#secondForm").validate({ // initialize form validation on form 2
            // rules & other options,
    
            errorPlacement: function(error, element) {
                $("#firstForm").valid();  // forces test on form 1 when form 2 has errors
                error.insertAfter(element); // default error placement
            },
            submitHandler: function(form) {
                if ($("#firstForm").valid()) {  // test to see if form 1 is valid before submitting form 2
                   form.submit;
                }
                return false;
            }
        });
    
    });
    

    $("#firstForm").valid() is used above in two locations for the following two cases:

    1) Form #2 is valid; so we must test for Form #1 validity within submitHandler: as a condition of form submission.

    2) Form #2 is invalid; so we must trigger a Form #1 validity test within errorPlacement:. Since we’re using errorPlacement:, we must specify it, or errors will not appear. In the example, I simply used the default error placement code.


    EDIT:

    In order to get second form to display errors at same time as first form, also add .valid() to the second form’s errorPlacement: option, which forces a test on form 1 when form 2 has an error. See edited code above.

    Working DEMO: http://jsfiddle.net/eLsDs/1/


    EDIT 2:

    I can’t see your HTML because you’ve not included it, but I modified my demo to include the code from your OP.

    Demo using OP’s code: http://jsfiddle.net/eLsDs/2/

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

Sidebar

Related Questions

I have been using hidden values for forms. Example: <form method=post action=page.php> <input type=text
I have 2 forms that both point to the same functions.php page 1 form
I have a form page in PHP that reads a DBF, and conditionally converts
I have a contact page (contact.php) that sends a form (formsend.php) when people fill
I have a PHP page that queries a DB to populate a form for
I have a form on one page, and the submit button on that page
I have multiple forms like so: <form method=post action=change.php id=form1> <input name=product_id type=hidden value=abc
I have a php page called form.php. When you go to this page it
I have am HTML form in a PHP page. The form has various inputs.
I have a Create new account page. The form is in page named Register.php

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.