HTML DOM Input FileUpload disabled Property


The HTML DOM FileUpload disabled property returns and modify the value of disabled attribute of a FileUpload input type in HTML.

Syntax

Following is the syntax −

1. Returning disabled

object.disabled

2. Setting disabled

object.disabled = true|false;


Example

Let us see an example of HTML FileUpload disabled property −

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
   body{
      background-color:#397367;
      color:#fff;
      padding:10px;
   }
   p{
      font-size:1.2rem;
   }
   input{
      width:200px;
      border:none;
      margin:10px 0;
   }
   .btn{
      display:block;
      margin:10px 0;
      background-color:#22223B;
      color:#fff;
      border:none;
      height:30px;
      border-radius:50px;
      font-weight:bold;
      padding:0.5rem 1rem;
      cursor:pointer;
      outline:none;
   }
</style>
</head>
<body>
<h1>FileUpload disabled Property Example</h1>
<p>Are you able to choose file?</p>
<input type="file">
<button onclick="enableDis()" class='btn'>Enable/Disable Choose File</button>
<script>
   function enableDis() {
      var chooseFileBtn = document.querySelector("input");
      if(chooseFileBtn.disabled === true){
         chooseFileBtn.disabled = false;
      } else {
         chooseFileBtn.disabled = true;
      }
   }
</script>
</body>
</html>

This will produce the following output −

Output

Click on “Enable/Disable Choose File” button to enable/disable Fileupload input type.

raja
Published on 16-Jul-2019 14:10:44
Advertisements