Javascript Dialog Box
| Function | Description |
|---|---|
| alert() | To give alert message to user |
| prompt() | To input value from used |
| Confirm() | To get confirmation from user before executing |
Alert()
Alert() function in JavaScript is used to give an alert message to the user.
Example
<!DOCTYPE html>
<html>
<body>
<script>
function alertmsg()
{
alert("Alert function call");
}
</script>
</body>
<form>
<input type="button" value="Click Me" onclick="alertmsg()"/>
</form>
</html>
Try Now
prompt()
Prompt function in JavaScript is used to get input from user.
Example
<!DOCTYPE html>
<html>
<body>
<script>
function alertmsg()
{
a=prompt("Enter your name:");
alert(a);
}
</script>
</body>
<form>
<input type="button" value="Click Me" onclick="alertmsg()"/>
</form>
</html>
Try Now
Confirm()
Confirm function in JavaScript is used to get confirmation from user before executing some task.
Example
<!DOCTYPE html>
<html>
<body>
<script>
function alertmsg()
{
a=prompt("Enter your name:");
confirm(a);
}
</script>
</body>
<form>
<input type="button" value="Click Me" onclick="alertmsg()"/>
</form>
</html>
Try Now
