In an attempt to solve a similar situation I've come across this example and adapted it. It uses JQUERY UI Dialog as Nikhil D suggested. Here is a look at the code:

HTML:

<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<input type="button" id="box" value="Confirm the thing?" />
<div id="dialog-confirm"></div>

JavaScript:

$('#box').click(function buttonAction() {
  $("#dialog-confirm").html("Do you want to do the thing?");

  // Define the Dialog and its properties.
  $("#dialog-confirm").dialog({
    resizable: false,
    modal: true,
    title: "Do the thing?",
    height: 250,
    width: 400,
    buttons: {
      "Yes": function() {
        $(this).dialog('close');
        alert("Yes, do the thing");
      },
      "No": function() {
        $(this).dialog('close');
        alert("Nope, don't do the thing");
      }
    }
  });
});

$('#box').click(buttonAction);

I have a few more tweaks I need to do to make this example work for my application. Will update this if I see it fit into the answer. Hope this helps someone.

Answer from FredFury on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › met_win_confirm.asp
Window confirm() Method
A confirm box is often used if you want the user to verify or accept something. A confirm box takes the focus away from the current window, and forces the user to read the message. Do not overuse this method.
🌐
PHPpot
phppot.com › javascript › javascript-confirm
JavaScript Confirm Dialog Box with Yes No Alert - PHPpot
This function returns a boolean true or false based on the button clicks on the confirm dialog box. ... This example connects the on-click event and the JS handler created for showing the confirm box. This JS code contains the HTML to display two buttons “Edit” and “Delete”. Each has the onClick attribute to call the JavaScript custom handler doAction(). ...
🌐
Envato Tuts+
code.tutsplus.com › home › coding fundamentals
Confirm Yes or No With JavaScript | Envato Tuts+
July 21, 2021 - So that’s how you can use the confirm method in JavaScript to present a yes or no selection dialog box.
🌐
SitePoint
sitepoint.com › javascript
Yes / No Confirm Alert Box - JavaScript - SitePoint Forums | Web Development & Design Community
December 30, 2005 - Is there a predefined way to display a Message to the user giving them a Yes and No button that is as easy to code as Alert in JavaScript? What I what to do is provide the user a confirm box after the click the delete b…
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › confirm
Window: confirm() method - Web APIs | MDN
const windowButton = document.querySelector("#windowButton"); const log = document.querySelector("#log"); windowButton.addEventListener("click", () => { if (window.confirm("Do you want to open in new tab?")) { window.open("https://developer.mozilla.org/en-US/docs/Web/API/Window/open"); } else { log.innerText = "Glad you're staying!"; } }); Dialog boxes are modal windows — they prevent the user from accessing the rest of the program's interface until the dialog box is closed. For this reason, you should not overuse any function that creates a dialog box or a modal window.
Find elsewhere
🌐
Coderanch
coderanch.com › t › 121474 › languages › JavaScript-confirm
JavaScript confirm with Yes/No (HTML Pages with CSS and JavaScript forum at Coderanch)
I need to create a confirm box in javascript with yes/no options. is it possible without using VB script? ... Please take the time to choose the correct forum for your posts. This forum is for questions on JSP. This post has been moved to a more appropriate forum. [Asking smart questions] [About Bear] [Books by Bear] ... You can create a div that looks like a prompt box and display it on top, other than that there is no way to do it.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1188726 › how-do-i-create-a-pop-up-yes-no-message-box-called
How do I create a pop up Yes/No message box called from and return the result to C# code? Javascript? Something else? - Microsoft Q&A
So, the only "trick" in above is that most JavaScript routines are asynacrours, and don't wait. However, as above shows, we get around this issue by adding a "flag" variable to above and passing the btn control. This means that no hidden controls, or even fancy js await commands are required.
🌐
Javascript
javascript.nexus › posts › making-yes-no-alert-javascript
Making a yes no alert in Javascript | Javascript Nexus
July 28, 2023 - Prompting a user with a custom alert message asking them to confirm or cancel their action.
🌐
Wells Fargo
wellsfargo.com › privacy-security › fraud › report › phish
How to Spot, Avoid, and Report Phishing Scams | Wells Fargo
When you receive an urgent request that doesn’t seem right, hang up or close the message. You aren’t being rude — you are being wise. ... Wells Fargo offers additional security options for signing on to your account. Learn more about our enhanced security tools and authentication options. Be sure to use the Wells Fargo Mobile® app to regularly monitor your account for suspicious activity. You can also turn on additional alerts to be notified of transactions and withdrawals.
🌐
Techfry
techfry.com › home › javascript tutorial › javascript interaction: alert, prompt, confirm
JavaScript Interaction: alert, prompt, confirm - Tech Fry
It returns true for OK and false for Cancel or Esc. ... This shows a message and pauses script execution until the user presses "OK". For example: ... The mini-window with the message is called a modal window. The word "modal" means that the visitor can’t interact with the rest of the page ...
🌐
MUI
mui.com › material-ui › react-alert
React Alert component - Material UI
A key trait of the alert pattern is that it should not interrupt the user's experience of the app. Alerts should not be confused with alert dialogs (ARIA), which are intended to interrupt the user to obtain a response. Use the Material UI Dialog component if you need this behavior. import Alert from '@mui/material/Alert'; CopyCopied(or $keyC)
🌐
sebhastian
sebhastian.com › javascript-confirmation-yes-no
JavaScript - Create confirmation box with yes and no options | sebhastian
July 6, 2022 - You can create a JavaScript confirmation box that offers yes and no options by using the confirm() method.
🌐
Canva
canva.com › home › ai code generator
AI Code Generator: Transform your designs with coding-free creations | Canva
Add your idea or prompt in the search bar. Then select "Generate code". Pick what you like and open it in the editor to customize further. ... Yes. Administrators for Teams, Enterprise, and Education accounts can enable or disable all of Canva’s AI tools from their Admin Panel. ... Yes, you can now ...
🌐
Experts Exchange
experts-exchange.com › questions › 29221462 › How-to-create-a-dialog-with-Confirm-and-Cancel-options-in-JavaScript.html
How to create a dialog with “Confirm” and “Cancel” options in JavaScript? | Experts Exchange
July 31, 2021 - Select allOpen in new window assuming this HTML (I cannot give you a working fiddle since they block prompt and confirm · <div id="div1"> Submit this? </div> <div id="cancel" class="hide"> Never mind </div> <form id="myForm"> <input type="submit" value="OK" /> </form> ... Hello Michel, Thank you for your time and help. Upon running your code, it shows me the OK button. But noting happens when clicked.
🌐
JavaScript in Plain English
javascript.plainenglish.io › chapter-120-mastering-javascript-dialog-boxes-alert-confirm-and-prompt-explained-7f1cf1279e99
Chapter 120:Mastering JavaScript Dialog Boxes: Alert, Confirm, and Prompt Explained | by Aryan kumar | JavaScript in Plain English
October 24, 2024 - When building interactive web applications, user interaction often requires immediate feedback or responses. This is where JavaScript dialog boxes come in. JavaScript provides three main types of dialog boxes: alert(), confirm(), and prompt(). These boxes serve different purposes, from notifying users to gathering input.
🌐
TestMu AI Community
community.testmuai.com › ask a question
How to create a dialog with “Yes” and “No” options in JavaScript? - TestMu AI Community
April 16, 2025 - Once the user clicks the button, I want to show a dialog with “Yes” and “No” options. If the user selects “Yes”, the data will be inserted into the database; if “No”, no action will be taken.
🌐
Quora
quora.com › How-do-you-create-a-dialog-with-yes-and-no-options-in-JavaScript
How to create a dialog with “yes” and “no” options in JavaScript - Quora
Answer (1 of 2): In the future, I would strongly recommend Googling questions like this prior to asking. The answer is readily available. You want to use the confirm method. You pass in the message you would like to display in the dialog as the argument like the following [code ]confirm(‘Click y...