JavaScript confirm Box

« Previous Tutorial Next Tutorial »

The confirm box in JavaScript is used to display a message and return a true or false value.

JavaScript confirm Box Example

Here is an example demonstrates confirm box in JavaScript:

   <title>JavaScript confirm Box</title>

<h3>JavaScript confirm Box Example</h3>
<script type="text/javascript">
   var checkval = confirm("Are you sure to delete this file ?");
      document.write("Welcome to! <br/>You have successfully deleted the file.");
      document.write("Welcome to! <br/>The file is not deleted.");


Here are some sample outputs of the above JavaScript confirm box example. This is the initial output produced by the above JavaScript code:

javascript confirm box

This is the output after pressing OK button:

javascript confirm box example

This is the output after pressing Cancel button:

confirm box javascript

JavaScript Online Test

« Previous Tutorial Next Tutorial »

© Copyright 2021. All Rights Reserved.