JavaScript Window prompt()
JavaScript Window prompt()
The prompt() method is used to display a dialog box that prompts the user for input. If the user clicks OK button, then it will return the user response i.e, their input else it will return null. A prompt box is a box that is used if we want the user to input a value. When it pops up, the user will either have to click Cancel or OK to further proceed.
Syntax:-
Its syntax is:- prompt(text, defaultText)
Return:-
Its return is:- if the user click OK then the user response else null
Further Explanation:-
Parameter | Description |
text | Required.The text we want to display in the dialog box. |
defaultText | Optional. The default input text. |