Disable/enable a form element using jQuery?

There are two ways to disable/enable form elements.

Set the 'disabled' attribute to true or false:

// Disable #x
$('#x').attr('disabled', true);
// Enable #x
$('#x').attr('disabled', false);

Add or remove the 'disabled' attribute:

// Disable #x
$("#x").attr('disabled', 'disabled');
// Enable #x
$("#x").removeAttr('disabled');

Most Popular

Connect to Amazon EC2 instance using Filezilla and SFTP

Pan Card Validation Using Javascript

Customize wordpress register form wp_register()