JavaScript Confirm Popup Yes, No Button Instead of Ok and Cancel

Javascript Confirm popup Yes, No button instead of OK and Cancel

Unfortunately, there is no cross-browser support for opening a confirmation dialog that is not the default OK/Cancel pair. The solution you provided uses VBScript, which is only available in IE.

I would suggest using a Javascript library that can build a DOM-based dialog instead. Try Jquery UI: http://jqueryui.com/

Make javascript alert Yes/No Instead of Ok/Cancel

You can use jQuery UI Dialog.

These libraries create HTML elements that look and behave like a dialog box, allowing you to put anything you want (including form elements or video) in the dialog.

Yes/No buttons instead of OK/Cancel in a confirm() dialog?

I don't believe so. In JS, confirm() is specified to only use the OK and Cancel buttons.

If you want something more complicated, you'll have to make your own dialog, or use a third-party one that provides your desired functionality (yes, including jQuery, unfortunately).

How to create a dialog with “Ok” and “Cancel” options

You’re probably looking for confirm(), which displays a prompt and returns true or false based on what the user decided:

if (confirm('Are you sure you want to save this thing into the database?')) {  // Save it!  console.log('Thing was saved to the database.');} else {  // Do nothing!  console.log('Thing was not saved to the database.');}

Yes or No buttons on confirmation box

You can't do this with confirm. There is no way to customize the buttons of the native alert/confirm/etc dialogs.

You could make a DOM-based dialog instead, and customize the elements to your liking.

how to create yes/no/cancel box in javascript instead of ok/cancel?

You can't.

Instead, you can use a fake dialog library, such as jQuery UI Dialog.

These libraries create HTML elements that look and behave like a dialog box, allowing you to put anything you want (including form elements or video) in the dialog.



Related Topics



Leave a reply



Submit