Confirm box example in JavaScript

In this post, we will discuss Confirm box example in JavaScript. Also, you can check out my previous posts on:
The confirm dialog box is used to confirm a user’s answer to a question. A question mark will appear in the box with an OK button and a Cancel button. If the user presses the OK button, true is returned; if he presses the Cancel button, false is returned.
<script language=”JavaScript” type=”text/javascript”>
        if (confirm(“Are you sure you want to do this?”) == true) {
            alert(“You have clicked OK !!!”);
        else {
            alert(“You have clicked Cancel !!!”);
When run this, the window will appear like below:
If you click on OK, the alert will come like below:
And if you click on Cancel, the alert will come like below:
Check out Best Alternative to InfoPath -> Try Now


New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

(Installation & Features)

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →