Powered by Blogger.

Thursday, February 27, 2014

Confirm box example in JavaScript

In this post we will discuss about Confirm box example in JavaScript. Also you can check out my previous posts on:

- Error functions in sql server

- How To Call a Button Click From Another Button in C#.Net?

- Post form data to 3rd party URL in Asp.Net

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: