Vaibhav Jain
Vaibhav Jain

Reputation: 34407

Find if a textbox is disabled or not using jquery

I need to find if a textbox is disabled or enabled using Jquery.

Upvotes: 117

Views: 195461

Answers (5)

sshow
sshow

Reputation: 9094

You can use $(":disabled") to select all disabled items in the current context.

To determine whether a single item is disabled you can use $("#textbox1").is(":disabled").

Upvotes: 17

Rajat Bansal
Rajat Bansal

Reputation: 955

 if($("element_selector").attr('disabled') || $("element_selector").prop('disabled'))
 {

    // code when element is disabled

  }

Upvotes: 6

user4272288
user4272288

Reputation:

You can check if a element is disabled or not with this:

if($("#slcCausaRechazo").prop('disabled') == false)
{
//your code to realice 
}

Upvotes: 6

ShankarSangoli
ShankarSangoli

Reputation: 69905

You can find if the textbox is disabled using is method by passing :disabled selector to it. Try this.

if($('textbox').is(':disabled')){
     //textbox is disabled
}

Upvotes: 85

Joseph Silber
Joseph Silber

Reputation: 219938

.prop('disabled') will return a Boolean:

var isDisabled = $('textbox').prop('disabled');

Here's the fiddle: http://jsfiddle.net/unhjM/

Upvotes: 182

Related Questions