Check if input is disabled and then alert but something is wrong

As there just detect that is not disabled but how is that possible when disabled with jQuery and also set on html side a disabled attribute?

So how can detect if this disabled on mousedown and display an alert. Why is got from else alert message?


Since disabled control elements can’t have events bound to them, you’d need to bind an event to an ancestor element and make a check to see whether the target was the input.

You can then go on to check if it’s disabled, and if so, show your alert:

$(document).ready(function() {  
  $(document).on('mouseup', function(e){
      if( == "fileInput" &&{
        alert('CLICKED, BUT DISABLED!!');
            alert('Not disabled. =)');

Now, this test is done using a type = "text", in your case with the type = "file", there is a problem.

input[type=file] is very peculiar input type, you can’t really do a whole lot with it, primarily for security reasons.

I hope I have helped

1 Like