title: How to impose maxlength on textArea in HTML using JavaScript
body: <p>I would like to have some functionality by which if I write</p>
  
  <pre><code>&lt;textarea maxlength="50"&gt;&lt;/textarea&gt;
  &lt;textarea maxlength="150"&gt;&lt;/textarea&gt;
  &lt;textarea maxlength="250"&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>it will automatically impose the maxlength on the textArea. If possible please do not provide the solution in jQuery.</p>
  
  <p>Note: This can be done if I do something like this:</p>
  
  <pre><code>&lt;textarea onkeypress="return imposeMaxLength(event, this, 110);" rows="4" cols="50"&gt;
  
  function imposeMaxLength(Event, Object, MaxLen)
  {
      return (Object.value.length &lt;= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode&gt;=35&amp;&amp;Event.keyCode&lt;=40))
  }
  </code></pre>
  
  <p>Copied from <em><a href="https://stackoverflow.com/questions/451491/what-is-the-best-way-to-emulate-an-html-input-maxlength-attribute-on-an-html-te">What is the best way to emulate an HTML input “maxlength” attribute on an HTML textarea?</a></em></p>
  
  <p>But the point is I don't want to write onKeyPress and onKeyUp every time I declare a textArea.</p>