Javascript Reference - HTML DOM Input FileUpload disabled Property








The disabled property disables or enables sets a file upload button.

Browser Support

disabled Yes Yes Yes Yes Yes

Syntax

Return the disabled property.

var v = fileuploadObject.disabled 

Set the disabled property.

fileuploadObject.disabled=true|false 

Property Values

Value Description
true|false Disable or enable a file upload button.
  • true - The file upload button is disabled
  • false - Default. The file upload button is not disabled




Return Value

A Boolean type value, true if the file upload button is disabled, otherwise false.

Example

The following code shows how to get if a FileUpload button is disabled.


<!DOCTYPE html>
<html>
<body>
<!--from   w w  w .  ja v a  2s . com-->
Get file: <input type="file" id="myFile" disabled>
<button onclick="myFunction()">test</button>
<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myFile").disabled;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to disable and enable a FileUpload button.


<!DOCTYPE html>
<html>
<body>
<!-- ww w .ja  v  a 2s.c  o m-->
Get file: <input type="file" id="myFile">
<button onclick="disableBtn()">Disable File Upload</button>
<button onclick="enableBtn()">Enable File Upload</button>

<script>
function disableBtn() {
    document.getElementById("myFile").disabled = true;
}
function enableBtn() {
    document.getElementById("myFile").disabled = false;
}
</script>

</body>
</html>

The code above is rendered as follows: