How do I prompt for input with a popup dialog in JavaScript?

Jorge Jordão

Use the prompt(message,inputDefault) window method. It returns the value entered by the user, or null if he pressed cancel.

      <SCRIPT LANGUAGE="JavaScript">
        var value = prompt("Enter a value:","");
        if (value != null) {
          alert("You entered " + value);
        else {
          alert("You canceled!");
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.