Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Text Area Limit Rows

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
0
0
US
I have a page with a free format text area in an input form. I would like to validate the text entered into the form to limit it to 5 rows. When the submit button of the form is clicked I can of course trigger validation of the text area. I cannot visualise how I can count the number of lines a user has filled in to set up an error message when more than 5 lives have been typed in. Of course it also has to handle a user entering just a couple of words on a line and hitting enter.

 
Skittle:

There is no way to limit the amount of text entered. The only fix would be an event that is fired on the submit of the form to make sure the number of characters does not exceed a certain amount:

function CheckLength(maxchars){
if(document.forms["formname"].textareaname.value.length >
maxchars) {
alert('Too much data in the text box! Please remove '+
(document.forms["formname"].textareaname.value.length - maxchars)+ ' characters');
return false; }
else
return true; }


I hope this helps,
[yinyang]
Patrick
 
Hmm I was afraid of that.

OK. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top