Javascript: How to disable submit button until all fields are validated?
<p>I have several validation functions that work fine and I want to write an additional validation in simple javascript (<strong>no jQuery, etc</strong>) for the entire form that disables/enables the Submit button depending on whether the other validation functions return true or false.  How do I go about that?</p>

<p>For example, for my main HTML I have:</p>

<pre><code> &lt;form id="form" method="POST"&gt;
      &lt;label class="form"&gt;Field 1&lt;/label&gt;&lt;input type="text" name="input1" onkeyup="validateInput1(); return false"&gt;
      &lt;label class="form"&gt;Field 2&lt;/label&gt;&lt;input type="text" name="input2" onkeyup="validateInput2(); return false"&gt;
      ...
      &lt;button id="submit" type="submit" value="submit"&gt;Submit&lt;/button&gt;
 &lt;/form&gt;
</code></pre>

<p>For my script I have:</p>

<pre><code> function validateInput1(){
 ...
 }

 function validateInput2(){
 ...
 }
</code></pre>

<p>Now I want to write a function with something like:</p>

<pre><code>function validateForm(){

    var submitButton = document.getElementById('submit');
    submitButton.disabled = true;

    /*If all other validation functions like validateInput1() returns true then submitButton.disabled = false*/
}
</code></pre>

<p>How do I do this?</p>