title: Javascript - Enable Submit button when all input is valid
body: <p>So I have a form with some inputs (First and last name, user name, birthday, password and email) with some validation conditions which I made like this for example :</p>
  
  <pre><code>function checkfnlname(field) {
  curr = document.getElementById(field).value;
  if ( curr.length &gt; 0) {
      updateCSSClass(field, 1);
      return true;
  }
  else {
      updateCSSClass(field, 0);
      return false;
  }}
  </code></pre>
  
  <p>This changes it's color and return true . I call these function using <code>onKeyUp=""</code>. Now what I want to do is make the Submit button disabled until all the fields have been completed and validated by the functions up there. I wrote this function :</p>
  
  <pre><code>function formvalid() {
  if (checkfnlname('fname') &amp;&amp; &amp;&amp; (all other fields)) {
      document.getElementByID("submitinput").disabled = false;
  }
  else {
      document.getElementByID("submitinput").disabled = true;
  }
  return 1;}
  </code></pre>
  
  <p>But I have no idea how/where to call it. (I tried a lot of things I found but nothing worked)
  Is this the right way to do it ? if so how can I call this function ?</p>