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.

Leave a Reply

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

7 + 4 =

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="">