Member-only story
JavaScript — How to make an input pop up box
Oct 1, 2022
How to Make An Input Pop Up Box in JS
Use the prompt() method.
The Window.prompt()
displays a dialog with an optional message prompting the user to input some text.
What is prompt()
- displays a dialog box for the user input
- can be used for the user to input a value before entering a page
- returns the input value if the user clicks “OK”
- returns null if the user clicks “CANCEL”
What to keep in mind when using prompt()
- user will have to click “OK” or “CANCEL” to proceed after entering an input value
- overuse prevents the user from accessing other parts of the page until the box is closed!