The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Chat2 Reply To: Chat2

Ilan Firsov

Without seeing the code we can only guess, but I think I know what your problem is.
As far as I can tell <input /> tags by default submits the form when you press the enter key while <textarea /> does not.
If you don’t need multiple lines you can just change the <textarea /> to <input /> and everything should be fine
You can force <textarea /> to submit the form with Javascript:

      <textarea id="multiline"></textarea>
 $('#multiline').on('keypress', function(e) {
      if(e.which == 13) {

And if you want to have multiline support with let’s say CTRL+Enter, just add this to the keypress callback function:

   if(e.ctrlKey && e.which == 10) { //when ctrl is pressed enter input code is 10 instead of 13
        $(this).append("\n"); // \n = line break

Here is a quick Pen

  • I’m using jQuery here, but it should be fairly easy in vanilla JS as well