chetan
chetan

Reputation: 3255

confirmation modal dialog in javascript

Is it possible to get confirmation dialog with yes , no option instead of ok,cancel in javascript ?

Upvotes: 3

Views: 5952

Answers (4)

Thulasiram
Thulasiram

Reputation: 8552

$('<div></div>').appendTo('body')
                    .html('<div><h6>Are you sure?</h6></div>')
                    .dialog({
                        modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true,
                        width: 'auto', resizable: false,
                        buttons: {
                            Yes: function () {
                                // $(obj).removeAttr('onclick');                                
                                // $(obj).parents('.Parent').remove();

                                $(this).dialog("close");
                            },
                            No: function () {
                                $(this).dialog("close");
                            }
                        },
                        close: function (event, ui) {
                            $(this).remove();
                        }
                    });

for Demo :

Upvotes: 0

Mike Sherov
Mike Sherov

Reputation: 13427

Not with the native confirm function. You would have to use a custom dialog. Fortunately, there are a lot of good ones available, check out jQuery and it's plug-ins.

Upvotes: 1

Kris van der Mast
Kris van der Mast

Reputation: 16613

The default confirmation box is baked into browsers. But you can make use of modal dialogs with the little help of plugins like jQuery UI Dialog or BlockUI.

Upvotes: 2

Pekka
Pekka

Reputation: 449395

Not using the native browser functions, no.

You would have to use a custom dialog class like jQuery dialog.

Upvotes: 6

Related Questions