Handle Textarea key event and limit enter pressed - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Handle Textarea key event and limit enter pressed

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from   ww  w.  j av  a  2 s  .  c  o m*/
document.getElementById("myTextArea").addEventListener("keydown", function (e) {
    if (e.keyCode == 13) {
        e.preventDefault();
    }
});
    }

      </script> 
   </head> 
   <body> 
      <textarea id="myTextArea">Test</textarea>  
   </body>
</html>

Related Tutorials