How to disable all <input > inside a form with jQuery?

Viewed 215178
<form id="target">
....
</form>
8 Answers

With this one line you can disable any input field in a form

$('form *').prop('disabled', true);

You can do it like this:

//HTML BUTTON
<button type="button" onclick="disableAll()">Disable</button>

//Jquery function
function disableAll() {
    //DISABLE ALL FIELDS THAT ARE NOT DISABLED
    $('form').find(':input:not(:disabled)').prop('disabled', true);

    //ENABLE ALL FIELDS THAT DISABLED
    //$('form').find(':input(:disabled)').prop('disabled', false);
}
Related