jquery - prevent empty submissions in <textarea> -


I received a & lt; Textarea & gt; And the keystrokes which have been selected I have installed it where the user records the press, the text written in the text field will be submitted to a database.

However, I want to stop submitting blank text, just entering and submitting I also noticed that when a new row is created, then I can not just check That's the text "" or its length is 0 because the second time there will be a new line.

Use the keyboard to find jQuery:

  $ (document) .ready (function () {$ ('. Active-friend-tab div # Chat-window form # chat-message (key> = 33) {var maxLength = $ (this) .attr ("text message") ('keydown', function (event) {var key = event.which; Maxlength "); var length = this.value.length; if (length> gtl; maxLength) {event.preventDefault ();}}}) $ $ ('active-friend-tab div # chat-window form # chat - Message text message # message ') Live (' keyup ', function (e) {if (e.keycode == 13) {var text = $ (this) .val (); var maxLength = $ (this) Attr ("mactland") var; length = text; height = $ ('ac tive-buddy-tab div h3 p # t O '). Text (); if (length = lt; = maxLength + 1) {chat.send (from text, from); Chat.update (from, from); $ (This) .val ("") ;} And {$ (this) .val (text. Substring (0, maxlainth))}}}})}};  

How can I stop sending an empty message Am? If this is really simple, then maybe I'm thinking very hard about it. I

Thanks, Hryto

  if ($ .trim ($ (This) .val ()) == "") // blank  


Comments