Differentiate between confirm and alert methods | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Differentiate between confirm and alert methods

28th Sep 2016, 10:36 AM
Màahi Śharmá
Màahi Śharmá - avatar
2 Answers
+ 2
Alert() The alert() dialog box is used to communicate a message to the user (generally warnings of missed actions). For example, if the email address entered is wrong, you can use the alert() message to warn the user about it. Confirm() The confirm dialog box is used to confirm a user’s answer to a question. This method takes only one argument, the question you will ask the user. A question mark will appear in the box with an OK button and a Cancel button. If the user clicks the OK button, true is returned; if he or she clicks the Cancel button, false is returned. This is also a modal dialog - the user must agree before the action is completed. prompt() The prompt() method asks the user for some small input such as a password, completion of a form input, or personal information, such as nickname or title. The prompt dialog box pops up with a simple text box. After the user enters text into the prompt dialog box, its value is returned (or null in case the user hit cancel).
28th Sep 2016, 3:13 PM
Oliver Brown
Oliver Brown - avatar
0
alert box is just show the message but confirm box will ask you to confirm either yes or no.
28th Sep 2016, 12:40 PM
Moorthi R
Moorthi R - avatar