How do I prompt for input with a popup dialog in JavaScript?
Created May 4, 2012
Jorge Jordão
Use the prompt(message,inputDefault) window method. It returns the value entered by the user, or null if he pressed cancel.
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
var value = prompt("Enter a value:","");
if (value != null) {
alert("You entered " + value);
}
else {
alert("You canceled!");
}
</SCRIPT>
</HEAD>
</HTML>