Prompt dialog Box is used to have an input from the users or to get confirmation on any input.
This dialog box is displayed using a method called prompt() which takes two parameters:-
(i) A label which you want to display in the text box.
(ii) A default string to display in the text box.
It is mostly used when you want to pop-up a text box for users input.
It enables you to interact with the users and the user only need to fill in the fields and then click OK.
It displays a dialog box with two buttons:
Cancel and OK.
If the user clicks on the Cancel button, the window method prompt() returns null.
Similarly when the user clicks on the OK button, the window method prompt() will return the entered value from the text box.
Have a look on this simple example to understand the concept of prompt dialog box:-
<p>Click on the button below to see how prompt dialog box works </p>
<input type="button" value="Click Me" onclick="getConfirmation();" />
var retVal = prompt("Enter your name : ", "your name here");
document.write("You have entered : " + retVal);