JavaScript

How to show a confirmation message before delete

In this tutorial, we are going to see how to display a confirmation message before deleting with JavaScript.

The confirmation message is required before submitting the deletion request to the server. Usually, the confirmation box appears before the deletion request is processed. You can easily display a confirmation dialog using the window.confirm() method on the client-side.

The confirm() method displays a dialog box with a message and two buttons (OK and Cancel). This method returns true if the user clicks OK, otherwise false.
 

 

How to show a confirmation message before delete
<button onclick="confirm()">Supprimer</button>
function confirmation(){
    var res = confirmation("Are you sure you want to delete?");
    if(res){
        // Put the deletion logic here
    }
}


mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *