Javascript alert popup with two buttons OK / Cancel or Yes / No

How can I add another button to javascript alert popup window, to have two buttons with values OK / Cancel or Yes / No ?
08 Dec 2020 at 04:44 PM
0pnshow more

To get javascript "alert like" box with OK and Cancel button, you have to use confirm() function. It works similar to alert() function, but it displays two buttons with possibility to create positive and negative condition:

var val = confirm("Type your text here.");
if (val == true) {
alert("You pressed OK.");
} else {
alert("You pressed Cancel.");

09 Dec 2020 at 09:54 AM
0pnshow more
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us