The disabled
property disables or enables sets
a file upload button.
disabled |
Yes | Yes | Yes | Yes | Yes |
Return the disabled property.
var v = fileuploadObject.disabled
Set the disabled property.
fileuploadObject.disabled=true|false
Value | Description |
---|---|
true|false | Disable or enable a file upload button.
|
A Boolean type value, true if the file upload button is disabled, otherwise false.
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:
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: