title: Javascript: Enter does not work for submitting password
body: <p>I can't get the following code working: when I press enter in the text-box, the function is not called. I can't see why though...</p>
  
  <pre><code>&lt;form&gt;
  &lt;p align="center"&gt;
  &lt;input type="password" class="password" name="text1" onkeypress="submitonenter(text1.value,"money","cash",event)" /&gt;&lt;br&gt;
  &lt;input type="button" value="Enter" style="width: 100px" name="Enter" onclick=javascript:validate(text1.value,"money","cash") /&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
      function submitonenter(text1,text2,text3,evt) {
          evt = (evt) ? evt : ((window.event) ? window.event : "")
          if (evt) {
              // process event here
              if ( evt.keyCode==13 || evt.which==13 ) {
  
   if (text1==text2)
   load('money/welcome.html');
   else 
   {
    if (text1==text3)
    load('cash/welcome.html');
     else
     {
     load('failure.html');
     }
   }
  
              }
          }
      }
  &lt;/script&gt;
  
  &lt;script language = "javascript"&gt;
  function validate(text1,text2,text3)
  {
   if (text1==text2)
   load('money/welcome.html');
   else 
   {
    if (text1==text3)
    load('cash/welcome.html');
     else
     {
     load('failure.html');
     }
   }
  }
  function load(url)
  {
   location.href=url;
  }
  &lt;/script&gt;
  </code></pre>