SHARE
TWEET

Disable enter key for selected submit buttons within a form

a guest Mar 22nd, 2012 53 Never
  1. <html>
  2.     <head>
  3.         <script type='text/javascript'>
  4. function keyPressed(e)
  5. {
  6.      var key;      
  7.      if(window.event)
  8.           key = window.event.keyCode; //IE
  9.      else
  10.           key = e.which; //firefox      
  11.  
  12.      return (key != 13);
  13.  }
  14.         </script>
  15.     </head>
  16.     <body>
  17.         <form action="1">
  18.             <input type="text" />
  19.         </form>
  20.         <form action="2">
  21.             <input type="text" onKeyPress="return keyPressed(event)"/>
  22.         </form>
  23.     </body>
  24. </html>
RAW Paste Data
Top