Javascript confirmation dialog box

Javascript confirmation dialog box is used to display a message to the user for confirming something.
Note: Confirmation dialog box gives two button “OK” and “Cancel”. The confirm() method returns true if Ok button is clicked else returns false.


<!DOCTYPE html>
function getConfirmation(){
  var retVal = confirm("Do you want to continue?");
  if( retVal == true ){
       document.write ("User wants to continue!");
        return true;
        document.write ("User does not want to continue!");
        return false;
<p>Click Submit button and see result.</p>      
 <input type="button" onclick="getConfirmation()" value="Submit" />

Try it:

JS Bin on

Comments are closed.