If we want to get an input before proceeding then we should use window prompt.
Suppose we want to check whether the user is 18+ or not.
Basic Syntax :-
prompt(text, [default]);
text: The text displayed in the prompt box.
default: A default value for the input field (optional).
Examples var age = prompt("Are you 18+ ?");
console.log(age);
// Prints the value inserted by the user
Suppose we want to check whether the user is 18+ or not.
Basic Syntax :-
prompt(text, [default]);
text: The text displayed in the prompt box.
default: A default value for the input field (optional).
Examples var age = prompt("Are you 18+ ?");
console.log(age);
// Prints the value inserted by the user
We have two button one is ok and second is cancel, if we select ok then entered value will be returned or null.
While the prompt box is displayed, the user is prevented from accessing other parts of the page, since dialog boxes are modal window.
No comments:
Post a Comment