How to use Confirmation Dialog Box in JavaScript

In this article we will discuss about how to make Confirmation Dialog Box in JavaScript.
  • 2492

JavaScript supports three types of  DialogBox one of which is confirmation DialogBox. This DialogBox is used to ask whether the user want to continue or not and it shows two buttons Ok and Cancel. To use the Confirmation Dialog Box we will use confirm() method in JavaScript and when the user click on Ok button then it will return true and if user will click on Cancel button the conform() method will return false.

JavaScript Code:



    <script type="text/javascript">


        function confirmation() {

            var value = confirm("Do you want to continue ?");

            if (value == true) {

                alert("You want to continue!");

                return true;

            } else {

                alert("You do not want to continue!");

                return false;








        Click this button to see the result:



    <input type="button" value="Click" onclick="confirmation();" />







Ask Your Question 

Got a programming related question? You may want to post your question here
© 2020 DotNetHeaven. All rights reserved.