Use JavaScript alert() box in HTML

In this article i will explain how to use javascript alert box in HTML.

we use alert box mostly for a giving a warning message to user.
we use alert box for validation purpose, if there is empty textbox while submitting form we display message in alert box enter some value.

Here we will learn alert() box with HTML Example.

Write javascript alert() box code in <head> tags like below :

<head runat=”server”>
<script type=”text/javascript” language=”javascript”>
function mm()
{
alert(“Hi Meera Academy”);
}
</script>
</head>

First Design HTML web form for learn javascript alert() box.

JavaScript alert() box in HTML

JavaScript alert() box in HTML

Here is the HTML form code :

<html>
<head>
<script type=”text/javascript” language=”javascript”>
function mm()
{
alert(“Hi Meera Academy”);
}
</script>
</head>
<body>
Use JAvaScript Alert Box in HTML
<form>
<input type=”button” value=”JavaScript Alert” onclick=”mm()” />
</form>
</body>
</html>

Here we use onclick property of button control for call javascript function.

JavaScript alert() box in HTML

JavaScript alert() box in HTML

 

Leave a Reply

Your email address will not be published. Required fields are marked *

8 + 3 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">