tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

prevent_return_key.html (891B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Prevent return key should not submit form</title>
      6  <script type="application/javascript">
      7  function init() {
      8    let input = document.getElementById("input");
      9    input.addEventListener("keydown", function(aEvent) {
     10      if (aEvent.keyCode == 13) { // return key
     11        alert("Hello!");
     12        aEvent.preventDefault();
     13        return false;
     14      }
     15      return true;
     16    }, {once: true});
     17 
     18    let form = document.getElementById("form");
     19    form.addEventListener("submit", function() {
     20      let result = document.getElementById("result");
     21      result.innerHTML = "submitted";
     22    }, {once: true});
     23  }
     24  </script>
     25 </head>
     26 
     27 <body onload="init()">
     28  <form id="form">
     29    <input type="text" id="input">
     30    <button type="submit" id="submitBtn">Submit</button>
     31  </form>
     32  <p id="result">not submitted</p>
     33 </body>
     34 </html>