Creating a dialog box with buttons on a web page

In my web application when a user clicks on close button i want a box to appear with following content :
Text : Changes you made will not be saved
Buttons :
1) Close
2) Don’t close

I tried using the window.confirm  It shows dialog like :
Screen-Shot-2016-07-29-at-12.13.59-P.pngI couldnt find how to change the names of the buttons.
Some places its mentioned that you cannot change it. What alternative ways are there ?

Rohit BajajAsked:
Who is Participating?
Mukesh YadavConnect With a Mentor Full Stack DeveloperCommented:
Yes this is not possible to change these values.

To use something different you can go with Bootbox confirm method.
PawełConnect With a Mentor SharePoint DeveloperCommented:
if you are using the front end just use the jquerUI modal dialog, it'll be more work, but yes as far as i know you can't modify the buttons in a window.confirm, just like you cant change then button on the alert.
Rohit BajajAuthor Commented:
Is jquery UI installable while npm ?
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Rohit BajajAuthor Commented:
I tried using require("jquery-ui");
installed it using npm install jquery-ui.
But getting error on this line :     $("#dialog").dialog({ autoOpen: false });
TypeError: $(...).dialog is not a function
On this sample page :
They are using 3 jquery related libraries.
for jquery i am already using 2.1.4 version.
PawełSharePoint DeveloperCommented:
I don't think you've included jqueryUI correctly

i think you're going to have to download Jquery UI and add it manually.

I should also mention i'm not familiar with NPM
Mukesh YadavFull Stack DeveloperCommented:
Hi Rohit,

Can you please close this question by accepting a solution, If current answers doesn't work for you please tell us what issue  you are facing.

Mukesh Yadav
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.