I guess because a text area implies multiple lines of text, and the user may well press the enter key inadvertantly at the end of a line or deliberately to create a new paragraph. If that causes the form to submit prematurely he may well be annoyed.
A textbox has only one line and if the user presses enter it is most likely that he has finished his entry.
The Following 2 Users Say Thank You to Philip M For This Useful Post:
Except that this function is for a chat, so NOT being able to press enter is annoying.. using a textbox is too small, and you lose track of what your writing... textarea is bigger and it wraps.. i just need it to be able to press enter.. now, i tried that site and it submitted when i pressed enter, except nothing happened.. it was as though no variables were passed or something...
var charCode = (evt.which) ? evt.which : window.event.keyCode;
if (charCode == 13)
if you want to get even trickier you can use prototype's nifty event handling to even set actions based on the id of your choice. for example, tossing the following in if you're using prototype would get you the id of the element the enter key was hit in:
var id = Event.element(evt);
then you could decide whether or not you want an action to occur based on the id. just a thought. i use something like this on a big webform with ajax updater to submit everything and update on the fly.
throw a return false in there if you like. should kill the literal keypress. then figure out why it doesn't like your submit... which is probably where the problem is. i've got that code in a live web app being used by bunches of people using both ie and ff, with no complaints... it does work.