title: Form Submission Goes To Javascript - And Stay On Same Page
body: <p>Please consider the following non-working HTML document:</p>
  
  <pre><code>&lt;html&gt; 
      &lt;body&gt;
          &lt;form action="" method="GET" onsubmit="return f(this);"&gt;
              &lt;input type="text" name="bar" value="" /&gt;
              &lt;input type="button" name="foo" value="foo" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
      &lt;script type="text/javascript"&gt;
          function f(x) {
              alert(x.bar);
          }
      &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What I am trying to achieve is that when either (a) the foo button is pressed; or (b) enter is pressed while the text input has focus; then the function f is called with the content of the s text input - and the browser should otherwise stay on the same page after f returns.</p>
  
  <p>How can I achieve this?</p>