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.
Example:
<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 !!!”);
        }
    </script>
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

You May Also like the Following SharePoint Online Tutorials:

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 SharePointSky.com

View all posts by Bijay Kumar →