jQuery
jQuery Disable Input Textbox Examples
Using jQuery you can easily disable input. These input can be textbox, textarea, etc. Read on to find out easy it is to disable input using jQuery.
Use jQuery to Disable Input Textbox
Let’s assume that you have an input box with the ID “first_name”. You can disable it using the following code:
Disable input using jQuery:
$("#first_name").attr('disabled','disabled');Enable disabled input using jQuery:
$("#first_name").removeAttr('disabled');Enable / Disable Input using prop() method in jQuery
In jQuery 1.6+, a new method ( called prop() ) has been introduced that you can use. The following is the sample code:
//To disable input
$("#first_name").prop('disabled', true);
//To enable input
$("#first_name").prop('disabled', false);Your Turn!
Do you know of any other ways to disable input using jQuery? Feel free to suggest by commenting below.