Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

text area delimitation

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
Alejandro_Lopez
Asked:
Alejandro_Lopez
  • 2
2 Solutions
 
ThGCommented:
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
 
DesertWarriorCommented:
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
 
DesertWarriorCommented:
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now