Javascript confirmation dialog box

The Javascript confirmation dialog box is used to display a message to the user to confirm something.
Note: Confirmation dialog box gives two buttons “OK” and “Cancel”. The confirm() method returns true if the 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>