Function “prompt”

function prompt(message[, default_value])

Prompts the user to enter a text

Parameters

NameTypeDescription
messagestringA message to display in front of the text edit control
default_valuestring (optional)Optional parameter defining the initial text value

Return Value

Returns the entered text if the user confirms the dialog and an empty string if the user closes the dialog.

Example

name = prompt("Please enter a new name:")
if (name.length > 0)
	alert("Your new name is: " + name, "Name Chosen");