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.
<script type=”text/javascript”>function show()
         var name=prompt(“Enter your name”,”Meera Academy”);
if (name!=” “)
alert(“Hello ” + name );



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

Example of Prompt box in ASP.Net.

  • Below screen show the HTML coding with prompt box.
(Visited 14 times, 1 visits today)

Leave a Reply

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

Captcha *