javascript - Limit text in a TextArea to the actual Area of the TextArea -


When asking about most questions about TextError, I do not want this. I want to know how to limit the editable area of ​​textare HTML element to actual textarea. Is this also possible.

Example:

Say I have Textaria, which is from 30 columns 4 rows. You can limit the text to this field to 120 characters, but it can not stop the user from hitting 5 times and I have already set it up for the given area. I do not want to come to a scroll bar.

Is there a javascript that can fix it?

text with visibility: hidden display with font styles similar to Texter and Copy to a max-width , which will not increase beyond the number of your columns if the hidden copy of the text exceeds your threshold, delete the text that was added.

The following shut down is what you need. Unfortunately, it does not get to the 5th line (after entering the 4th row) until you type something on it, and it may leave some letters on the 5th line (if you are from the fourth row Wrap in the 5th line). I am unsure of refining this technique further.

  var $ measures = $ ('#make'); Var $ input = $ ('#input'); Var $ output = $ ('# measurement'); Var existing text = ''; $ Input.on ('keyup', function (event) {$ measure.html ($ input.val ()); $ output.val ($ measure.width () + 'x' + $ measure.height () + 'Px'); if ($ measure.height ()> 60) {$ input.val (current text. Transmitter ()); $ measure.html (existing text).}}}} Existing text = $ input.val ();});  
  #major {status: absolute; Visibility: hidden; Height: auto; Width: Auto; White-space: Pre-wrap; / * Set Font Style, equivalent to Texture Style * / font-family: monospace; Font size: 13px; Alphabets: General; Line-height: Normal; Word-spacing: 0; Word-wrap: break-word; Max-width: 221 pixels; Border: 1x solid black; Margin: 2px; Padding: 2px; }  
  & lt; Script src = "https://ajax.googleapis.com/ajax/libs/JQuery/1.1.1/jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Textarea id = "input" cols = "30" rows = "4" & gt; & Lt; / Textarea & gt; & Lt; Div id = "measurement" & gt; & Lt; / Div & gt; & Lt; Br> & Lt; Input type = "text" disabled = "disabled" id = "measure" />  


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -