SQL PHP HTML ASP JavaScript articles and free scripts to download If you are facing any problem in viewing this page, please tell us
 

Displaying Alert window with message


By using JavaScript prompt we can ask the visitor to enter data to our system for further processing. The prompt command will display a window and ask visitor to enter some data. We can collect the data entered by the user and store them in a variable. Here is some example.

var my_string = prompt("Please enter your name");
document.write(my_string)


We can show some default text while displaying the prompt. Here is an example where a default message is displayed for the visitor to enter first name.

var my_string = prompt("Please enter your name","enter your first name only");
document.write(my_string)

The above code will display the prompt window with some default text.

We can check the entered data by using if else condition.
Here is the demo of this code. Click the button below to display the prompt message.


Further readings
window.onload: for functions to execute as soon as page loads
Displaying alert window with message
prompt window for user input
Confirm window for user choice
Opening a child window
Closing child window on click of a button
Refreshing parent window from child window
Passing of data from child window to parent window
Showing a conformation window to user before deleting
Displaying JavaScript pop up window
Sections
PHP
JavaScript
ASP
HTML
SQL
Photoshop
Articles SEO
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.