Enable or disable an input field with jQuery

jQuery serialize()

Using jQuery prop() method you can enable or disable a form element. From jQuery 1.6+ you can use jQuery prop() method.

You can enable or disable an elements on a page dynamically with jQuery by setting their attributes accordingly.

For jQuery 1.5 and below the .prop() function doesn’t exist, but .attr() method does similar thing.

Disable a Control:

$( "#elementID" ).prop( "disabled", true );

Enable a Control:

$( "#elementID" ).prop( "disabled", false );

Also Read:

Using .attr():

Set the disabled attribute:


To enable again you can use .removeAttr():


This will totally remove the disabled attribute from the element instead of blanking it out.

Read jQuery reference for more details.

For any types of queries, you can contact us on info@namasteui.com.

Leave a Reply

Your email address will not be published. Required fields are marked *