birdy
birdy

Reputation: 9646

how to enable the submit button only when an element in the form has changed

I've implemented this with the code below:

$(':input[type!="submit"]', form.get(0)).live ('change', function (e) {
    form.find (':submit').removeAttr ('disabled');
});

This works perfectly, however, when the user changes the element back to its original state, the submit button is still enabled:

Example:

Upvotes: 0

Views: 964

Answers (1)

j08691
j08691

Reputation: 208032

Try this:

$(document).on('change', 'input[name=cb1]', function () {
    $('input[type=submit]').prop('disabled', $(this).is(':checked'));
});

jsFiddle example

I'm using .on()'s event delegation based on your your use of .live().

Upvotes: 1

Related Questions