Prev Demo
JavaScript
>
How To Show A Prompt Box In Javascript?
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Prompt Box and Functions with Parameters</h1> <script> function PromptUser() { var yourName = prompt('What is your name?', ''); if (yourName != null && yourName != "") { alert("Your name is [" + yourName + "]"); } } </script> <input type="button" id="btnTest" onclick="PromptUser()" value="Click me!" /> </body> </html>
Note: We DO NOT save your trial code in our database.
Output