Write this in onclick event of the button:
var result = confirm("Want to delete?");
if (result) {
//Logic to delete the item
}
Answer from Ved on Stack OverflowHey peeps.
I was having a chat with a colleague about deleting items and bulk clearing fields in a form. He asked what about how should we confirm the deletion. (Not how we confirm the intention - we have a pattern for that and it is a pretty common confirmation popup dialog) How does the system confirm to the user that the action has gone thru.
I was arguing that the fact that the content from the fields or the file in question being no longer present is enough of a confirmation of that distructive action taking place. He was proposing a green success toast message with a "Deletetion successful" type message - and the team agrees that this (out of 3 types of visual confirmations) is the way.
Is it something that I am missing here? Because I still feel that less is more in this case. Why bother with an extra message?
microcopy - What are some alternatives to the phrase "Are you sure you want to XYZ" in confirmation dialogs? - User Experience Stack Exchange
How to suppress or modify Delete confirmation message
iMessage delete confirmation - Apple Community
How to handle delete confirmation from within a modal?
Videos
Part of the reason that people skip over long messages is due to reading speed.
Assume for the sake of discussion someone with an average reading speed - around 200 words per minute.(*)
If you use just 20 words in a dialog, you're asking that user to spend 6 seconds reading and understanding what you wrote.
While that doesn't sound like much, a six second imposed pause when you're trying to get something done can seem to be an awfully long time.
(*) And don't make the mistake of assuming that low reading speed means low intelligence.
So, three suggestions for you, all aimed at maximum clarity with minimum fuss.
- Be as concise as possible
- Identify the item at risk
- Name your buttons for the actions
Here is a simple deletion dialog:

Let's reduce the number of words to the minimum to make it easier to read:
Now, let's identify the item at risk, and label the buttons for the action:

Much better - easier to read and clearer.
Another example - a continuation dialog.

Simplify wording.
Again, let's identify what's going on and label the buttons for the actions.

A definite improvement.
Here's a final thought. Avoid negatives, especially double negatives. Some native English speakers find double negatives tricky, and many who learn English as a second language find them confusing (especially if their native tongue uses double-negatives for emphasis instead of inversion).
I always make a point of showing the user which item is being deleted (especially since the dialogue might obscure the item in question, but also because seeing identifiable text in the dialogue will call attention):
Delete "your favourite item"?
You can also inject a little humour here and there, depending on what kind of app you're making:
Surely you don't want to continue without saving? [Yes I do, leave me alone] [Oh right, thanks for reminding me]
If you user test it you'll notice that humorous messages get noticed a bit more frequently simply because they sort of stand out from the crowd of generic messages and (if they're actually cute enough) get a smile on the face of the user. What more could you want?