{"id":125,"date":"2014-04-23T12:09:00","date_gmt":"2014-04-23T11:09:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/04\/23\/differentiate-between-alert-prompt-and-confirmation\/"},"modified":"2014-04-23T12:09:00","modified_gmt":"2014-04-23T11:09:00","slug":"differentiate-between-alert-prompt-and-confirmation","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/04\/23\/differentiate-between-alert-prompt-and-confirmation\/","title":{"rendered":"Differentiate between alert(), prompt() and confirmation()?"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>1 Minute, 43 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<h4 style=\"color: #222222; line-height: 21.559999465942383px; margin: 0px; position: relative;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">alert() dialog<\/span><\/h4>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">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. Developers also use alerts() as a quick and dirty way to debug their applications.<\/span><\/div>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<pre style=\"border-style: none; color: black; direction: ltr; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 720px;\"><span style=\"background-color: white; font-family: Times, Times New Roman, serif;\"><span style=\"color: green;\">\/\/ warning<\/span>\nalert(<span style=\"color: #006080;\">\"Invalid email address. Please enter again.\"<\/span>);\n<span style=\"color: green;\">\/\/ debugging<\/span>\nalert(currentCounter);<\/span><\/pre>\n<\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">The alert() method creates a new pop-up window (dialog box) which contains the user message and an<br \/>OK button. This is a modal window and all execution is stopped until the user clicks the OK button in the pop-up box.<\/span><\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<a href=\"http:\/\/lh6.ggpht.com\/-4cwYB0KYwng\/TepiI6DwpMI\/AAAAAAAACf8\/qeCdqudETYc\/s1600-h\/image%25255B7%25255D.png\" style=\"background-color: white; color: #888888; text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"font-family: Times, Times New Roman, serif;\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" src=\"http:\/\/lh5.ggpht.com\/-zaSbU-ziQOA\/TepiJWJh9nI\/AAAAAAAACgA\/AYl25q4homc\/image_thumb%25255B5%25255D.png?imgmax=800\" height=\"181\" style=\"-webkit-box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; background-image: none; border: 0px; box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; display: inline; padding: 0px 0px 5px; position: relative;\" title=\"image\" width=\"342\" \/><\/span><\/a><\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<h4 style=\"color: #222222; line-height: 21.559999465942383px; margin: 0px; position: relative;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">prompt() dialog<\/span><\/h4>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">The&nbsp;<em>prompt()&nbsp;<\/em>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).<\/span><\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<pre style=\"border-style: none; color: black; direction: ltr; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 720px;\"><span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">prompt(<span style=\"color: #006080;\">\"Please enter your nickname\"<\/span>, <span style=\"color: #006080;\">\"nickname\"<\/span>);<\/span><\/pre>\n<\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">The prompt method takes in 2 arguments \u2013 the prompt message and a default value. The default value is optional and if provided is filled in the text box and is selected by default.<\/span><\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<a href=\"http:\/\/lh5.ggpht.com\/-AgrOORzrA-E\/TepiJjnw12I\/AAAAAAAACgE\/7gffEN1iiH8\/s1600-h\/image%25255B11%25255D.png\" style=\"background-color: white; color: #888888; text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><span style=\"font-family: Times, Times New Roman, serif;\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" src=\"http:\/\/lh6.ggpht.com\/-tteHjdrtcas\/TepiKWyGItI\/AAAAAAAACgI\/4DTZ-WmKc7Q\/image_thumb%25255B7%25255D.png?imgmax=800\" height=\"145\" style=\"-webkit-box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; background-image: none; border: 0px; box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; display: inline; padding: 0px 0px 5px; position: relative;\" title=\"image\" width=\"504\" \/><\/span><\/a><\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<h4 style=\"color: #222222; line-height: 21.559999465942383px; margin: 0px; position: relative;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">confirm() dialog<\/span><\/h4>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<span style=\"background-color: white; font-family: Times, Times New Roman, serif;\">The confirm dialog box is used to confirm a user\u2019s 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&nbsp; &#8211; the user must agree before the action is completed. You often see this in shopping cart applications just before placing the order or on file sharing sites just before you delete a file.&nbsp;&nbsp;<\/span><\/div>\n<p><span style=\"font-family: Times, Times New Roman, serif;\"><span style=\"background-color: white;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><\/span><br \/>\n<\/span><\/p>\n<div style=\"color: #222222; line-height: 21.559999465942383px;\">\n<pre style=\"border-style: none; color: black; direction: ltr; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; width: 720px;\"><span style=\"background-color: white; font-family: Times, Times New Roman, serif;\"><span style=\"color: blue;\">if<\/span> (confirm(<span style=\"color: #006080;\">\"Are you sure you want to delete your profile photo?\"<\/span>) == <span style=\"color: blue;\">true<\/span>) {\n    alert(<span style=\"color: #006080;\">\"Deleting photo...\"<\/span>);\n}\n<span style=\"color: blue;\">else<\/span> {\n    alert(<span style=\"color: #006080;\">\"Glad you decided against deleting the photo!\"<\/span>);\n}<\/span><\/pre>\n<p><span style=\"background-color: white; font-family: Times, Times New Roman, serif;\"><br \/><\/span><\/div>\n<p><span style=\"background-color: white; font-family: Times, Times New Roman, serif;\"><br style=\"color: #222222; line-height: 21.559999465942383px;\" \/><a href=\"http:\/\/lh5.ggpht.com\/-A4daYUCRC1E\/TepiKtnEiPI\/AAAAAAAACgM\/HcLkq45t8s0\/s1600-h\/image%25255B15%25255D.png\" style=\"color: #888888; line-height: 21.559999465942383px; text-decoration: none;\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" alt=\"image\" border=\"0\" src=\"http:\/\/lh5.ggpht.com\/-PfUC2_iq4ZA\/TepiLctNBUI\/AAAAAAAACgQ\/3PoBdzUswu4\/image_thumb%25255B9%25255D.png?imgmax=800\" height=\"177\" style=\"-webkit-box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; background-image: none; border: 0px; box-shadow: rgba(0, 0, 0, 0.0980392) 1px 1px 5px; display: inline; padding: 0px 0px 5px; position: relative;\" title=\"image\" width=\"396\" \/><\/a><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>alert() dialog 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. Developers also use alerts() as a quick and dirty way to debug their applications. [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[24],"tags":[],"class_list":["post-125","post","type-post","status-publish","format-standard","hentry","category-c-net"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"alert() dialog 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. Developers also use alerts() as a quick and dirty way to debug their applications.&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/125"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}