Easy learning with example program codes

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

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki