The confirmation message is mandatory before submitting the delete request to the server-side. When you want to verify the user or accept something, it always a good idea to confirm the request before processing. Mostly, the confirmation popup is shown before processing the delete request. You can easily display a confirmation dialog using Window confirm() method in the client-side.
The confirm() method show a dialog box with a message and two buttons (OK and Cancel). This method returns true, if the user clicks OK, otherwise false.
In the following example code snippet, we will show you how to display delete confirmation message with confirm() method using JavaScript.
<button onclick="confirmation()">Delete</button>
function confirmation(){
var result = confirm("Are you sure to delete?");
if(result){
// Delete logic goes here
}
}
You can also use confirm() method to show confirm box on anchor link (a href tag) click. In the following example code snippet, we will show how to display a confirmation dialog when clicking anchor link using onclick() event.
<a href="action.php" onclick="return confirm('Are you sure to delete?')">Delete</a>
thank you so much
ow my gadd! thanks for it this is what i been looking for so so long, thank you buddy i appreciate it you save me so goo!
thanks
Thank you for this