0

Is there a way to limit the number of characters in a textarea inline instead of defining a function??

Here is what I tried, no errors in chrome:

<textarea id="comments" name="comments" rows="10" cols="30" onkeydown="function(){if(document.getElementById('comments').value.length>=5) { return false; }}"></textarea>
IVAO CA-WM
  • 19
  • 4

2 Answers2

0

I guess what you want is

<textarea maxlength="... any number value ...">
frontend_dev
  • 1,693
  • 14
  • 28
0

You want the maxlength attribute

<textarea maxlength="50">
Enter text here...
</textarea>
Adam Konieska
  • 2,805
  • 3
  • 14
  • 27