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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:52:35+00:00 2026-06-04T22:52:35+00:00

I have a form on which I would like the user to confirm one

  • 0

I have a form on which I would like the user to confirm one of the values when they try to submit, and I would like the confirmation to occur in a jQuery UI modal dialog.

The code looks something like this:

valuesCheck = function(event) {
    $j("#proposal-form-errors")
        .dialog({
            modal: true,
            width: 600,
            title: 'Values Confirmation',
            buttons: {
                "Confirm values and submit proposal": function () {
                    $form = $j('form#proposal');
                    $form.addClass('values-confirmed');
                    $j(this).dialog("destroy");
                    $form.submit();
                },
                "Continue editing": function () {
                    $j(this).dialog("destroy");
                }
            }
        })
        .html('<p>Please confirm the selected values.</p>');
    event.preventDefault();
}

$j("form#proposal").submit(function(event) {
    var val1 = $j("#val1 option:selected").text();
    var val2 = $j("#val2").val();
    if (val1 && val2 && !$j(this).hasClass('values-confirmed')) {
        valuesCheck(event);
    } else {
        return true; // processing stops here after the first click.
    }
});

By setting breakpoints in Firebug, I can see that it all works as I would expect, except that after clicking the “Confirm values and submit proposal”, when it passes the “return true” line in the submit function, nothing happens. If I fire the submit event one more time, the form will actually submit.

I assume that the problem is related to “event.preventDefault()”, but without that, the modal dialog disappears and the form submits before confirmation can take place.

I have also tried calling the $form.submit() method again from within the valuesCheck handler, but to no avail.

How can I make that “Confirm values and submit proposal” button in the modal dialog actually submit the form when it is clicked?

  • 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-04T22:52:36+00:00Added an answer on June 4, 2026 at 10:52 pm

    Check out this jsfiddle. I distilled the functionality down to the bare essentials, so you’ll need to work it back into your real code, but it works.

    For posterity, here’s the code:

    # HTML
    
    <form id="proposal" action="http://google.com" method="get" target="_blank">
        <input name="q">
        <button type="submit">Search</button>
    </form>
    <div id="proposal-form-errors"></div>​
    
    # jQuery
    
    valuesCheck = function(event) {
        $("#proposal-form-errors")
            .dialog({
                modal: true,
                width: 600,
                title: 'Values Confirmation',
                buttons: {
                    "Confirm values and submit proposal": function () {
                        $form = $('form#proposal');
                        $form.addClass('values-confirmed');
                        $(this).dialog("destroy");
                        $form.submit();
                    },
                    "Continue editing": function () {
                        $(this).dialog("destroy");
                    }
                }
            })
            .html('<p>Please confirm the selected values.</p>');
    }
    
    $("form#proposal").submit(function(event) {
        if (!$(this).hasClass('values-confirmed')) {
            event.preventDefault();
            valuesCheck();
        }
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which I would like to store the values of in
We have a form which uses the JQuery Validation Plugin and would like to
I have a form which includes a data sheet. I would like to make
I have a nested form in which I would like the form fields to
I have a donation form which users fill out and I would like to
I would like to have one background thread which will copy the files through
I have a jsp form which takes in user details. On submit button it
In a customised form I would have a create Purchase Menubutton which opens a
I have a form which users must fill out and submit. The controller action
I have a form which users can add controls to and when they right

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.