2

How can I display a yes/no message box to the user on the client-side in Javascript?

I don’t want to display “OK” and “Cancel” to the user, which is the default behavior of the confirm function in Javascript. Any help will be appreciated.

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
Sheikh Rahat Ali
  • 1,293
  • 8
  • 37
  • 61
  • There is a easy to use plugin to do it here : http://stackoverflow.com/questions/6457750/form-confirm-before-submit –  Sep 27 '12 at 12:22

4 Answers4

4

You can't amend the Ok/Cancel of the default confirm box, but you can use a 3rd party library (such as jQuery/jQuery UI) which will give you what you need: http://jqueryui.com/demos/dialog/#modal-confirmation

Town
  • 14,706
  • 3
  • 48
  • 72
2

have a look at this jquery plugin http://www.84bytes.com/2008/06/02/jquery-modal-dialog-boxes/

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
1

I just posted in my blog an easy to use Yes/No message box that you can easily modify to fit your project.

Example:

SmallJS.message.modal('Do you want to click yes?', {
                buttons: {
                    ok: 'Yes',
                    cancel:'No'
                },
                onOK: function () {
                    SmallJS.message.show('Yes sir!', { animate:false});
                }
            })

You can see the source code at: http://www.waltersoto.com/javascript/javascript-yes-no-message-box

1

jQuery UI has modal confirmation boxes

http://jqueryui.com/demos/dialog/#modal-confirmation

mplungjan
  • 169,008
  • 28
  • 173
  • 236