Locking out a Multi-Line text box from Enter key

Discussion in 'HTML & Website Design' started by Gravereaper, Dec 9, 2008.

  1. #1
    I was wondering how we can lock a multi-line text box from enter key, i.e. when the user presses enter on my multi-line text book, it doesn't takes the cursor to a new line but instead stay at the same line.

    Actually I am trying to use a multi-line text book as a single-line text book ( for designing purposes ).

    I remember doing it back in the days, can't figure it right now :)
     
    Gravereaper, Dec 9, 2008 IP
  2. dejangex

    dejangex Peon

    Messages:
    113
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I found only this code that works in IE6 for me:
    
    <html>
    </head>
    <body>
    <script type="text/javascript">
    
    function noEnter(e){
    
    	if (e.keyCode == 13 )
    	{
    		event.returnValue = false;
    	}
    	
    }
    
    </script>
    <form>
    	<textarea onkeypress="noEnter(event)" /></textarea>
    </form>
    </body>
    </html>
    Code (markup):
    Try google with "javascript block key" or "javascript detect keypress" and similar.
     
    dejangex, Dec 9, 2008 IP