Javascript Alert Dialog Box

The Javascript alert dialog box is used to display a warning message to the users.
Note: Alert dialog box gives one button “OK”.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
function giveWarning() {
alert("Warning message.");
document.write ("Warning message.");
}
</script>
<p>Click Submit button and see result.</p>
<form>
<input type="button" onclick="giveWarning()" value="Submit" />
</form>
</body>
</html>