问题:
I have a jQuery dialog that requires the user to enter certain information.我有一个 jQuery 对话框,需要用户输入某些信息。 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.但是,我不知道如何从此功能启用和禁用对话框按钮。 What should I do?我该怎么办?
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');
}
}
})
});
解决方案:
参考一: https://stackoom.com/question/2QFI参考二: How can I disable a button in a jQuery dialog from a function?