ConfirmDialogue.js | Creating a Custom Confirm Dialog Popup with JavaScript

ConfirmDialogue.js is simple javascript dialog library, it allows users can create user-friendly confirmation dialog popup for the web app.

ConfirmDialogue.js - Creating a Customconfirmation Dialog Popup with JavaScript

AuthorLinksMade withLast update
Xn1ch1Office HomeJavaScriptAug 31, 2022

How to create a confirm dialog popup using ConfirmDialogue.js?

1.Import ConfirmDialogue.css and ConfirmDialogue.js in your html page

<link rel="stylesheet" href="ConfirmDialogue.css" />
<script src="ConfirmDialogue.js"></script>

2. Create a ConfirmDialogue instance with the following parameters:

  • trueButtonText: Confirm button text
  • falseButtonText: Refuse button text
  • cancelButtonText: Cancel button text
  • messageText: Confirm messages
  • titleText: Confirm title
const dialogue = new ConfirmDialogue({
      trueButtonText: "Yes",
      falseButtonText: "No",
      cancelButtonText: 'Cancel',
      messageText: "This one has another option, the cancel option for when you dont want to do anything",
      titleText: "More Buttons"

3.You can use dialogue.respond() to process the choice of users

if (await dialogue.respond()) {
  alert('You pressed yes');
} else {
  alert('You pressed no');

Leave a Reply

Your email address will not be published. Required fields are marked *