0

Is there a way to limit count of symbols by square of textarea. For example when I enter some text in the textarea it should stop after the text reaches the end of its visible area(right bottom corner).

More details: I want the input stops like on the screenshot below:

enter image description here

  • `textarea { overflow : hidden }`? You could also use `textarea { text-overflow : ellipsis }`. – Jace Cotton Nov 03 '13 at 16:36
  • do you realize your count will be different depending on os, browser, user settings ? – mikakun Nov 03 '13 at 16:39
  • @mikakun I realize that it is unusual task, nevertheless I think it might be some solutions. Maybe it can be unique browsers function. – Vadim Kalinin Nov 04 '13 at 13:38
  • @JaceCotton Thanks, but your suggestion doesn't suit this situation. I need to prevent any input from user after text reaches the end of textarea. – Vadim Kalinin Nov 04 '13 at 14:01

1 Answers1

2

Wow - I had no idea that <textarea> supported an onoverflow and onoverflowchanged events:

http://en.wikipedia.org/wiki/DOM_events

Plug in a JavaScript callback that annoys the user when they write one too many characters, and make the field about to overflow. And good luck characterizing the browser support for such a rare event...

Phlip
  • 5,253
  • 5
  • 32
  • 48
  • Thank you, also I have found another useful post http://stackoverflow.com/questions/10431659/can-i-detect-an-overflow-event-in-jquery – Vadim Kalinin Nov 04 '13 at 15:46