title: Limiting number of lines and letters in single line in textarea
body: <p><strong>Problem:</strong><br>
  I am trying to limit number of lines AND letters in each line in a textbox. </p>
  
  <p><strong>What i got so far:</strong><br>
  So far i managed to limit lines count using this:</p>
  
  <pre><code>var text = $(this).val();
  var lines = text.split("\n");
  
  if(e.keyCode == 13 &amp;&amp; lines.length &gt;= $(this).attr('rows')) { 
          return false;
      }
  </code></pre>
  
  <p>This won't allow user to push return key (keyCode 13) if the limit of lines is reached.  </p>
  
  <p><strong>The problem:</strong><br>
  Now i am trying to limit number of letters in a single line too, because if i reach end of my textarea (with return key) i still can hold a letter/write tons of text, and it will jump to another line when it reaches end of line. That way this limitation can be "cheated" and i am looking for a solution for that.</p>
  
  <p><strong>My ideas, not solving the problem:</strong>  </p>
  
  <pre><code>else{
      for(var i = 0; i &lt; lines.length &amp;&amp; e.keyCode != 13; i++) {
           if(lines[i].length &gt;= $(this).attr('cols')) {
               return false; // prevent characters from appearing
           }
       }
  }
  </code></pre>
  
  <p>I tried this to limit number of letters. That works, but it got flaws. If i reach max letters in one line (<strong><em>ANY</em></strong>), i <strong><em>CANT TYPE IN ANY LINE</em></strong> anymore. </p>
  
  <p><strong>I have no idea how to check only line i am typing in RIGHT NOW.</strong></p>