34,333
edits
Changes
→Displaying Message Box Dialogs
<form action="null">
<input type="button" value="Show Alert" onclick="window.alert('You do not have a valid password')" />
</form>
</pre>
* '''confirmation''' - used when a yes or no response needs to be obtained from the user. This dialog type displays with a message and "OK" and "Cancel" buttons. The method takes the message to be displayed to the user as an argument and retruns true or false depending on whether the user pressed "OK" or "Cancel":
<pre>
<script language="JavaScript" type="text/javascript">
function showConfirmation()
{
var result = confirm("Would you like to continue?");
if (result)
document.write("Continue");
else
document.write("Do not continue");
}
</script>
<form action="null">
<input type="button" value="Show Confirmation" onclick="showConfirmation()" />
</form>