title: How to disable file input if text field is used
body: <p>I need to disable a file input if a certain text input is used. Or, disable the text input if the file input is used. However, if the end user changes their mind, then I want to be able to enable the file input if the text input is empty, and vice versa.</p>
  
  <p>This works well to disable the file input if the text input is used. However, if I clear the text input, the file input remains disabled:</p>
  
  <pre><code>    $("#linkurl").on('keyup blur', function(){
          $('#link').attr('disabled', this.value.trim().length);
      });
  </code></pre>
  
  <p>I tried this, but it obviously didn't work:</p>
  
  <pre><code>    $("#linkurl").on('keyup blur', function(){
          if($.trim($("#linkurl").val()) === ''){
              $('#link').attr('disabled');
          }else{
              $('#link').removeAttr('disabled');
          }
      });
  </code></pre>
  
  <p>Here's my HTML:</p>
  
  <pre><code>&lt;form action="default.cfm" method="post" enctype="multipart/form-data" id="linkform"&gt;
  &lt;div id="formdiv"&gt;
  
      &lt;strong style="color: #ff0000;"&gt;Linked Text&lt;/strong&gt;: Enter the text you wish to display for the link.&lt;br/&gt;
      &lt;strong style="color: #ff0000;"&gt;URL&lt;/strong&gt;: Enter a URL if you wish to link to another website (include: http://).&lt;br/&gt;
      &lt;strong style="color: #ff0000;"&gt;PDF:&lt;/strong&gt; The PDF file you wish to upload.&lt;br/&gt;&lt;br/&gt;
  
      &lt;strong style="color: #ff0000;"&gt;Linked Text:&lt;/strong&gt;&lt;br/&gt;
      &lt;input type="text" name="linktext" id="linktext" required&gt;&lt;br/&gt;&lt;br/&gt;
      &lt;strong style="color: #ff0000;"&gt;URL:&lt;/strong&gt;&lt;br/&gt;
      &lt;input type="text" name="linkurl" id="linkurl" value="If link, enter here..." required&gt;&lt;br/&gt;&lt;br/&gt;
      &lt;strong style="color: #ff0000;"&gt;PDF:&lt;/strong&gt;&lt;br/&gt;
      &lt;input type="file" name="link" id="link" required&gt;
  
  &lt;/div&gt;
  
  &lt;div id="submitbox"&gt;&lt;input type="submit" value="Click to Create Link" id="updatebutton"&gt;&lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>One side of my head is completely bald from pulling my hair out over this. I'm open to suggestions if there's a better way...</p>
  
  <p>Thanks...</p>