tags:

views:

202

answers:

3

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:

  • disable the submit button
  • add a method that enbales the submit button to the onchange event for all the other inputs on the form

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

A: 

Something like this:

$("#myform").children().change(function(){
   $("#submit").removeAttr('disabled');
});
Darmen
+1  A: 

Try this:

$("form").submit(function() {
    $(this).find(":submit").attr("disabled", "disabled");
}).find(":input").change(function() {
    $(this).parent("form").find(":submit").removeAttr("disabled");
});
Gumbo
No "}" to match your "{" ?
Matthew Wilson
+2  A: 

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');
});
K Prime
Thank you very much :) !!!
Omu