How to use Prompt box in JavaScript

Prompt box in JavaScript

In the Prompt box, user will have two option  OK OR Cancel.
Prompt box allow user to input a value before click the OK OR Cancel Button.

If clicks “OK”, means true. If clicks “Cancel”, means false.
<html><head>
<script type=”text/javascript”>function show()
{
         var name=prompt(“Enter your name”,”Meera Academy”);
if (name!=” “)
{
alert(“Hello ” + name );
}

}
 </script>

</head>

<body>
<input type=”button” onclick=”show()” value=”show alert box” />
</body>
</html>

Example of Prompt box in ASP.Net.

  • Below screen show the HTML coding with prompt box.

Leave a Reply

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