There is a method confirm() which will solve this problem.
This Confirm() method displays the message with OK & Cancel button in the dialog box.
If You click Ok then it returns true & if you click Cancel then it will return false.
Confirmation are most often used to confirm an important actions that are taking place on a website.
Following is the small example of it.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<html>
<head>
<script type="text/javascript">
function validate()
{
var result=confirm("Select Ok/Cancel");
if (result==true)
{
alert("OK selected !");
}
else
{
alert("Cancel selected !");
}
}
</script>
</head>
<body>
<input type="button" onclick="validate()" value="Confirm button" />
</body>
</html> |