Omu
Omu

Reputation: 71188

jquery: disable submit button in a form and enable it onChange of any element on the form

I need to disable the disable the submit button on my form and to enable if the onchange event occurs for any other input on the form
so basically I need to:

anybody knows how to do this ? (especially the second one)

Upvotes: 1

Views: 4263

Answers (3)

Gumbo
Gumbo

Reputation: 655139

Try this:

$("form").submit(function() {
    $(this).find(":submit").attr("disabled", "disabled");
}).find(":input").change(function() {
    $(this).parent("form").find(":submit").removeAttr("disabled");
});

Upvotes: 1

K Prime
K Prime

Reputation: 5849

Using jQuery 1.4:

// To disable submit button
$('#myform').find (':submit').attr ('disabled', 'disabled');

// Re-enable submit
var form = $('#myform');
$(':input', form.get(0)).live ('change', function (e) {
    form.find (':submit').removeAttr ('disabled');
});

Upvotes: 2

Darmen Amanbay
Darmen Amanbay

Reputation: 4871

Something like this:

$("#myform").children().change(function(){
   $("#submit").removeAttr('disabled');
});

Upvotes: 0

Related Questions