How can I disable a button in a JQuery dialog from a function?

Posted by Draco on Stack Overflow See other posts from Stack Overflow or by Draco
Published on 2009-02-23T12:58:44Z Indexed on 2010/06/17 18:23 UTC
Read the original article Hit count: 229

Filed under:

Hi,

I have a JQuery dialog that requires the user to enter certain information. In this form I have a "continue" button. I would like this "continue" button to only be enabled once all the fields have content in them else it will remain disabled. I wrote a function that is called everytime a field status has changed however I don't know how to enable and disable the dialog button from this function. Any ideas?

Oops and I forgot to mention that these buttons were created as follows:

$(function() {
    $("#dialog").dialog({

    bgiframe: true,
      height: 'auto',
      width: 700,
      show: 'clip',
      hide: 'clip',
      modal: true,
      buttons: {
        'Add to request list': function() {
          $(this).dialog('close');
          $('form').submit();
        },
        'Cancel': function() {
          $(this).dialog('close');
        }
      }
    });

© Stack Overflow or respective owner

Related posts about jquery-ui