Prompt Dialog Box in javaScript

Prompt dialog box:

The prompt dialog box is very useful when a pop-up text box to used to get user input. Thus it enables to interact with the user. The user needs to fill in the field and then click OK.

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.
  • This dialog box with two buttons: OK and Cancel. If the user clicks on Ok button the window method prompt() will return entered value from the text box. If the user clicks on the Cancel button the window method prompt() returns null.

    Example:

    Result:

    	
    


    Read Also: