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



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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...