function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ahilya SrivastavaAhilya Srivastava 

How to add a confirm dialog to a command button?

I'd think this would work just fine, but it seems to prevent the action function from firing regardless of the confirm response
 
<apex:commandButton value="Remove All" action="{!removeAll}" rerender="form"
     status="LoadingStatus" onclick="return confirm('Are you sure?');"/>

 
Best Answer chosen by Ahilya Srivastava
Prabhat Kumar12Prabhat Kumar12
In my case, it was returning to controller method for both options( true or false) so then i changed it to the code below and it started to work.
 
onclick="if(!confirm('Are you sure?')){return false;}"

 

All Answers

Prabhat Kumar12Prabhat Kumar12
In my case, it was returning to controller method for both options( true or false) so then i changed it to the code below and it started to work.
 
onclick="if(!confirm('Are you sure?')){return false;}"

 
This was selected as the best answer
Naveen KNNaveen KN
Implement custom dialog box in salesforce lightning 

https://www.codekiat.com/2019/07/confirm-dialog-in-salesforce-lightning.html

--
Naveen K N