How to disable or enable a form element with jQuery?

You need 2 jQuery functions: attr and removeAttr.

To disable a form element such as a text input or a button (with a made-up id: #elm):

$("#elm").attr("disabled", "disabled");

To enable a disabled form element:


7 thoughts on “How to disable or enable a form element with jQuery?”

  1. The jQuery docs say to use prop() for things like disabled, checked, etc. Also the more concise way is to use their selectors engine. So to disable all form elements in a div or form parent.


    And to enable again.


  2. If you have one field to change, uou can also do it with $(‘#checkboxfield’)[0].disabled = true

  3. @wade: native javascript is always faster than the jquery way.. in your case use: document.getElementById( “checkboxfield” ).disabled = true…

Comments are closed.

Scroll to Top