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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:47:06+00:00 2026-06-14T20:47:06+00:00

Ok, so various forms of this question have been asked, but I can’t find

  • 0

Ok, so various forms of this question have been asked, but I can’t find enough information to make my particular case work, so here is the context of what I’m trying to do:

I have a form which has half of its elements displayed on the page like normal, and the other half of its elements are displayed in a modal (on the same page, but starts out hidden and with all elements pre-populated with info off of a DB, so they are valid by default). This form also has 2 submit buttons, one on the page at the bottom of the 1st half of elements, and another on the modal itself. When the first submit button is clicked, I want the form to perform regular native HTML5 validation (yes, it will have to perform this on the entire form, including those fields in the modal, however, as I said, they are pre-populated off of a DB so they will be valid by default).

However, once all elements on the page itself are valid, I DON’T want the form to submit yet. Instead, I want to display the Modal with the other half of the elements (again, already pre-populated with info from the DB – I want the user to confirm that info). When the submit button contained on the modal is clicked, I want it to perform the same regular HTML5 validation and then actually submit the form (as long as it’s all still valid).

So, I found the following jquery in another answer which allows the browser to perform the HTML5 validation on the form, but blocks the submit event:

    $(function() {
      $('#form').submit(function(event){

        // cancels the form submission
        event.preventDefault();

      });
    });

My problem is this, I only want the above jquery to run on the first submit button’s click, and not the second button’s click. If there is a way to do this, I think my problem will be solved. Again, the reason I’m doing this is because I want the user to confirm the information that is displayed on the modal which pops up before the entire form is completely submitted…I know I could mitigate this by not using a modal at all and having everything on the one page, but I really want to use the modal. Sorry if this question is misplaced, has already been answered, confusing, or anything else. If it is confusing or you need more explanation/code let me know and I will edit the question.

Thanks in advance.

  • 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-14T20:47:07+00:00Added an answer on June 14, 2026 at 8:47 pm

    So to do what you’re asking, this should do the trick:

     $(function() {
      //track whether the form has been submitted, define here so it persists across submit events
      var submitted = false;
      $('#form').submit(function(event){
        // the outer function's variables are available in the inner function
        if (!submitted) {
          event.preventDefault();
          submitted = true;
        }
      });
    });
    

    However I’m really not sure this is the best way to achieve your ultimate aim. Far better would be to use javascript validation (eg the jQuery validation plugin), validate the first section after a button click (not a submit) and then track whether the initial part of the form is valid or not, rather than whether it has been submitted, then decide to show the modal.

    ie do something like this (pseudocode, won’t work as is, just to illustrate approach):

     $(function() {
      $('#form').on('click','button.first', function(e){
        //check that the first part of the form is valid when the `<button class="first">` is clicked, if it is, show the modal:
        var firstSectionValid = $('#form').find('#first-section').validate();
        if (!firstSectionValid) {
          showModal();
        }
      });
    });
    

    Then just have one submit button in the modal section of the form.

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

Sidebar

Related Questions

I know that this question has been asked in various forms but my requirement
This question has been asked several times in various forms but I haven't found
This question has no doubt been asked in various forms in the past, but
This question has been asked in various forms in a number of different forums,
This is pretty easy question, but I have been unable to find the solution
I'm aware that this question has appeared in various forms before, but none of
This question has been asked in various guises. However. this is a slightly different
I imagine this question has been asked before (hasn't every question?), but I am
Please forgive if this question has been asked numerous times. I recently installed Eclipse
I have asked a question similar to this and received some great help, it

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.