title: Disable/Enable Submit Button until all forms have been filled
body: <p>I want my form submit button to be disabled/enabled depending on if the form is completely filled.</p>
  
  <p>When the inputs are filled, the disabled button changes to enabled. That works great.
  But I would like it to disable the button when an input gets emtied.</p>
  
  <p>This is my script:</p>
  
  <pre><code>&lt;script type="text/javascript" language="javascript"&gt;
      function checkform()
      {
          var f = document.forms["theform"].elements;
          var cansubmit = true;
  
          for (var i = 0; i &lt; f.length; i++) {
              if (f[i].value.length == 0) cansubmit = false;
          }
  
          if (cansubmit) {
              document.getElementById('submitbutton').disabled = false;
          }
      }
  &lt;/script&gt; 
  &lt;form name="theform"&gt;
  &lt;input type="text" onKeyup="checkform()" /&gt;
  &lt;input type="text" onKeyup="checkform()" /&gt;
  &lt;input id="submitbutton" type="submit" disabled="disabled" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>