faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

21 of 136 people (15%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Can I limit the number of rows a user can type into a TEXTAREA (IE5.5 only)??

Jun 13th, 2002 02:48
M. Expósito, Patrick Mullin,


some code...:
Only limit the number of new lines

<SCRIPT> 

function checkMaxRow (textarea, maxrow) 
{
var cantidad = textarea.value.match(/\n+/g);
var cuenta = cantidad?cantidad.length:0;
   	if (cuenta < maxrow) 
    	{ return true;}
  	else
	{
	textarea.selected = false;
	return false;}
}


</SCRIPT>

And the call to function:

<textarea name="observaciones" cols="120" rows="15" wrap="HARD" 
          ONKEYDOWN="return checkMaxRow(this, 14)">