【发布时间】:2013-01-07 16:28:09
【问题描述】:
在 asp 页面中使用 jquery 完成表单时启用或禁用提交按钮。 当用户填写所有必要的字段时,我想启用按钮并更改我的 asp 页面上的按钮类别 请帮助我,我找到了很多代码,但没有一个是我的工作 请帮我 我试过了
(function() {
$('form > input').keyup(function() {
var empty = false;
$('form > input').each(function() {
if ($(this).val() == '') {
empty = true;
}
});
if (empty) {
$('#register').attr('disabled', 'disabled'); // updated according to http://stackoverflow.com/questions/7637790/how-to-remove-disabled-attribute-with-jquery-ie
} else {
$('#register').removeAttr('disabled'); // updated according to http://stackoverflow.com/questions/7637790/how-to-remove-disabled-attribute-with-jquery-ie
}
});
})()
【问题讨论】:
-
您确定您的代码粘贴正确吗?它不以 $( 开头,并以 () 结尾。
-
您的提交按钮是否有属性 id="register"?浏览器有没有js报错?
-
是的,没有任何错误发生,我需要单独指定所有字段
标签: jquery css asp-classic