JavaScript Tips & Tutorials jQuery Tips & FAQ

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:


By Yang Yang

Hello, I'm Yang. I build online businesses that please people. Want to join in and post some useful articles on Shoot me a message.

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

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.


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

Beware of disabling form elements….. they won’t be seen in the server side……

Comments are closed.