title: Disable/Enable submit button and running this javascript every 1 second onload
body: <p>I need to disable the submit button when the required fields are not filled. But the script is not working. If anybody can help, thanks in advance.</p>
  
  <p>Html : </p>
  
  <pre><code>&lt;input type="submit" value="Submit" name="sub1" id="submit1"&gt;
  </code></pre>
  
  <p>Javascript : </p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
          function form_valid() {
          var u1=document.getElementById("#user1").value;
          var p1=document.getElementById("#pass1").value;
          var p2=document.getElementById("#pass2").value;
          var s1=document.getElementById("#school1").value;
  
          if ((u1 == null)&amp;&amp;(p1 != p2)&amp;&amp;(s1 == null))
          {
              document.getElementById("#submit1").disabled = true;                    
              document.getElementById("#submit1").setAttribute("disabled","disabled");  
          }
          else
              {
  
              document.getElementById("#submit1").disabled = false;
              document.getElementById("#submit1").removeAttribute("disabled");            
              }
          }
              function form_run() {
                  window.setInterval(function(){form_valid();}, 1000);
              }            
      &lt;/script&gt;
  </code></pre>
  
  <p>Body tag (HTML) : </p>
  
  <pre><code>&lt;body bgcolor="#d6ebff" onload="form_run();"&gt;
  </code></pre>