title: Submit a form in JS using onsubmit
body: <p>I ran into some issues when trying to execute a function upon form submit. I needed to add a min/max for the inputs.</p>
  
  <p>The code without <code>onsubmit="runFunction()"</code> works as it's suppose to but when I wrap it into a form and use <code>onsubmit="runFunction()"</code> the function runs once but it resets everything after it's done.</p>
  
  <p>The code looks like this:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form&gt;
      &lt;input class="numGuess" id="num0" min="0" max="9" autocomplete="off"&gt;
      &lt;input class="numGuess" id="num1" min="0" max="9" autocomplete="off"&gt;
      &lt;input class="numGuess" id="num2" min="0" max="9" autocomplete="off"&gt;
      &lt;input class="numGuess" id="num3" min="0" max="9" autocomplete="off"&gt;
      &lt;input type="submit" value="Is it correct?" onclick="checkValues()"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The function checkValues():</p>
  
  <pre><code>function checkValues(){
    arr2 = [];
    Object.keys(mainGuess).forEach(function(num){
      var iterated = mainGuess[num];
      console.log(iterated.value);
      arr2.push(iterated.value);
    })
    compareArray();
  }
  </code></pre>
  
  <p>compareArray() just checks if the input value is the same as another array.</p>
  
  <p>The function works as long as I don't use a form and use <code>onclick</code> which changes the background of the inputs to red if wrong and green if correct. If I wrap it in a form the function runs, I can see it run briefly for a moment before it resets everything.</p>