title: How to add submit button to an HTML form with JavaScript function?
body: <p>The following form triggers a JavaScript function upon the user pressing enter. However, I'd like the function to be triggered when the user presses a submit button.</p>
  <pre><code>&lt;form action=&quot;&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;query&quot; size=&quot;20&quot; class=&quot;hintTextbox&quot; id='emailinput' placeholder='email'&gt;
      &lt;input type=&quot;text&quot; name=&quot;query&quot; size=&quot;20&quot; class=&quot;hintTextbox&quot; id='variablesinput' placeholder='variables'&gt;
  &lt;/form&gt;
  
  
  $('#variablesinput').keypress(function (e) {
      if (e.keyCode == 13) {
          var email = $('#emailinput').val();
           var variable = $('#variablesinput').val();
          alert(email + variable);
      }
  });
  </code></pre>
  <p>Also, see here: <a href="https://jsfiddle.net/chrisguzman/7Tag3/5/" rel="nofollow noreferrer">https://jsfiddle.net/chrisguzman/7Tag3/5/</a></p>