title: Onsubmit function refreshes page
body: <p>Very basic code that I can't get to work. The onsubmit function gets called, but the page refreshes back to its original form as if it executes but then restarts the HTML. The console.log flashes but then disappears as if we've restarted the page.</p>
  <p>I've commented out the &quot;return false&quot; because that seems to not be making a difference.</p>
  <p>What silly mistake am I making? Thanks in advance.</p>
  <pre><code>&lt;form method=&quot;POST&quot; style=&quot;display: inline&quot; onsubmit=&quot;validateAnswer()&quot;&gt;
    &lt;label for=&quot;answer&quot; &gt;Secret Word&lt;/label&gt;
    &lt;input id=&quot;answer&quot; name=&quot;answer&quot; size=&quot;15&quot; type=&quot;text&quot; /&gt;
    &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;h5 id=&quot;answerText&quot;&gt;&lt;/h3&gt; 
  
   
   &lt;script&gt;
      function validateAnswer() {
        var y = document.getElementById(&quot;answer&quot;).value;
        console.log(&quot;y: &quot; + y);
        if ( y == &quot;YOU&quot; || y == &quot;You&quot; || y == &quot;you&quot; ){
            document.getElementById(&quot;answerText&quot;).innerHTML = &quot;Correct!&quot;; 
            // return false;
        } else {
            document.getElementById(&quot;answerText&quot;).innerHTML = &quot;Sorry, that's not correct&quot;;
          // return false;
          }
      }
   &lt;/script&gt;
  </code></pre>