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.

Example:

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

Try it:

JS Bin on jsbin.com