Show confirm using javascript

The confirm() method displays a dialog box with a specified message, along with an OK and a Cancel button. If the user clicks OK, the confirm method returns true. If the user clicks Cancel, the method returns false.

Confirmation are most often used to confirm an important actions that are taking place on a website.

<script type="text/javascript">
function validate()
var result=confirm("Select Ok/Cancel");
if (result==true)
alert("OK selected !");
alert("Cancel selected !");

<input type="button" onclick="validate()" value="Confirm button" />