Solved

text area delimitation

Posted on 2003-11-17
6
239 Views
Last Modified: 2010-04-06
HI

Is there any way to make a text area and not to show (or permit to write) the scroll bar,

<textarea style="overflow:hidden" rows="3" name="S1" cols="20" ></textarea>

it hides the scroll bar but don´t limit the entry only to 3 rows, and that's what i want

0
Comment
Question by:Alejandro_Lopez
  • 2
6 Comments
 
LVL 14

Accepted Solution

by:
ThG earned 125 total points
ID: 9768194
You have to use javascript to do that..
Here is the function i used to limit the total lenght of the inserted message:
You can change the stri.length check with a rows check.. probably counting the number of '\n' in the message. Quite trivial if you check char by char.

function maxLength(tbox)
{
  var stri = tbox.value;
  if (stri.length > 255) {
    alert('Please don\'t type more than 255 characters');
    tbox.value = stri.substring(0,255);
    return false;
  }
  else
    return true;
}
0
 
LVL 5

Assisted Solution

by:DesertWarrior
DesertWarrior earned 125 total points
ID: 9768202
textarea do NOT have a maxlength property
however, here is a function that can help you limit the user to enter a certain amount of characters
taken from : http://www.teratech.com/ColdCuts/cutdetail.cfm?cutid=310

<FORM NAME="NotesForm">
 <TEXTAREA
  NAME="OrderNotes"
  TABINDEX="1"
  ROWS="8"
  COLS="32"
  ONBLUR="textCounter(this,this.form.counter,256);"
  ONKEYUP="textCounter(this,this.form.counter,256);"></TEXTAREA><BR>
 <INPUT
  TYPE="text"
  NAME="counter"
  TABINDEX="999"
  MAXLENGTH="3"
  SIZE="3"
  VALUE="256"
  ONFOCUS="this.blur();"
  ONBLUR="textCounter(this.form.OrderNotes,this,256);"> characters remaining
</FORM>
 
function textCounter( field, countfield, maxlimit ) {
 if ( field.value.length > maxlimit ) {
  field.value = field.value.substring( 0, maxlimit );
  field.blur();
  field.focus();
  return false;
 } else {
  countfield.value = maxlimit - field.value.length;
 }
}
0
 
LVL 5

Expert Comment

by:DesertWarrior
ID: 9768234
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question