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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:17:32+00:00 2026-06-16T20:17:32+00:00

I have a basic javascript confirm dialog to confirm whether or not a user

  • 0

I have a basic javascript confirm dialog to confirm whether or not a user wants to proceed with an action. The dialog works correctly if the user simply clicks OK or Cancel. However, if the user clicks Cancel, then re-triggers the dialog, then clicks OK the form is not submitted.

I’ve included my code below, is there a better way to handle this when what I’m doing here?

$("#myButton").click(function (event) {
    var result = confirm("Are you sure?");
    if (result) {
        return true;
    } else {
        return false;
    }
});

Note that I’ve also tried event.preventDefault in place of return false and I see the same result.

  • 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-16T20:17:33+00:00Added an answer on June 16, 2026 at 8:17 pm

    Now I might get what you’re trying to achieve.
    Just bind the event to your form submit handler instead of the button click. This will also trigger, if the user is sending the form using his keyboard etc.

    <form id="wohoo" action="/somewhere">
        <input />
        <input type="submit" value="send me"/>
    </form>​
    
    $("#wohoo").submit(function () {
        var result = confirm("Are you sure?");
    
        return result;
    });​
    

    http://jsfiddle.net/2tSbJ/

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

Sidebar

Related Questions

I have this basic auto complete JavaScript that works well, but you need to
I have some pretty basic Javascript here which works just fine in Firefox but
I have a basic show/hide javascript that works, as long as i don't make
I'm not fluent in more than basic javascript, but I am looking to have
So I have a rather basic javascript problem which I have been slamming my
I am making a webapp. I have a fairly basic question about javascript performance.
I have a page with some very basic examples that use HTML/CSS/JavaScript. I'd like
I have this basic javascript code: window.resizeTo(1000,800) set to run when the page loads
I have coded a basic game in JavaScript and am working on a high
This is a real simple example, I have a basic JavaScript object with an

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.