Jump to content
Larry Ullman's Book Forums

How To Set Maximun Rows In A Textarea


Recommended Posts

I am having trouble trying to control the amount of data that a user can enter in a textarea on a form.

 

The code (just a small segment of the full page form that I have is as follows:

 

<hr />

<p><b>Special Notes Regarding this form information: </b></p>

<p><textarea cols="45" rows="5" name="comments" wrap="hard"> </textarea></p>

<br />

<hr />

 

I have the limit set at 5 rows, but when typing in the area, the user can continue on and on and this will be unacceptable. I have thought of a message to say only type on the first 5 lines, but that doesn't seem to be very professional.

 

Any help would be appreciated

 

Mahalo,

Link to comment
Share on other sites

Thought I posted here earlier? Maybe I forgot to push the Add Reply-button...

 

You can't check number of rows. What you can do is check for a certain LENGTH of the comment (and this should be about 5 rows)

 

Lets say that 255 characters.

 

§comment = §_POST['comment'];

if (strlen(§comment) < 255) {
  echo "You can only type 255 characters, Twitr style!";
}

// some other checks aswell

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...