469,304 Members | 1,888 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,304 developers. It's quick & easy.

Textarea max rows and max characters per row

I have read a number of posts with techniques for limiting the max
number of characters entered into a textarea, but I'm looking for some
advice on how to limit the number of rows and the number of characters
per row.

Basically, I need to allow users to enter up to 5 rows of data with up
to 40 characters per row, regardless of whether or not the user has
explicitly entered any line breaks. I also need to consider where to
break off each line without breaking in the middle of a word.

Any advice would be greatly appreciated.
Jul 20 '05 #1
2 13025
Hello,

Basically, row1 and row2 are seperated by a new line character ("\n").
Word wrapping visually shows multiple rows however it is still the same row.

So to limit number of rows, simply count how much new line characters there
are.

To limit characters per row, simply scan each row and check its length.

<script>
t = "hello\n" +
"world\n";

lines = t.split('\n');
</script>

This script will create an array which holds every line...
--
Elias
"Greg Ferris" <gr*****@ferris.net> wrote in message
news:88**************************@posting.google.c om...
I have read a number of posts with techniques for limiting the max
number of characters entered into a textarea, but I'm looking for some
advice on how to limit the number of rows and the number of characters
per row.

Basically, I need to allow users to enter up to 5 rows of data with up
to 40 characters per row, regardless of whether or not the user has
explicitly entered any line breaks. I also need to consider where to
break off each line without breaking in the middle of a word.

Any advice would be greatly appreciated.

Jul 20 '05 #2
Elias,
Thank you for the help. The issue isn't what happens when a user
enters a line break - I can detect that pretty easily. The issue is
how I treat an entry WITHOUT line breaks. In other words, if the user
types continuously, I need to then programatically create line breaks
for the user (instead of just wrapping), still following the rules
that there can only be five rows and 50 characters per row. Further,
when creating these breaks, I want to be sure that I'm not doing it in
the middle of a word.

Thanks,
Greg
"lallous" <la*****@lgwm.org> wrote in message news:<bu************@ID-161723.news.uni-berlin.de>...
Hello,

Basically, row1 and row2 are seperated by a new line character ("\n").
Word wrapping visually shows multiple rows however it is still the same row.

So to limit number of rows, simply count how much new line characters there
are.

To limit characters per row, simply scan each row and check its length.

<script>
t = "hello\n" +
"world\n";

lines = t.split('\n');
</script>

This script will create an array which holds every line...
--
Elias
"Greg Ferris" <gr*****@ferris.net> wrote in message
news:88**************************@posting.google.c om...
I have read a number of posts with techniques for limiting the max
number of characters entered into a textarea, but I'm looking for some
advice on how to limit the number of rows and the number of characters
per row.

Basically, I need to allow users to enter up to 5 rows of data with up
to 40 characters per row, regardless of whether or not the user has
explicitly entered any line breaks. I also need to consider where to
break off each line without breaking in the middle of a word.

Any advice would be greatly appreciated.

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Simon | last post: by
4 posts views Thread by wing | last post: by
5 posts views Thread by Jesper Rønn-Jensen | last post: by
11 posts views Thread by Les Paul | last post: by
8 posts views Thread by Mark D. Smith | last post: by
6 posts views Thread by Tony | last post: by
1 post views Thread by Garry Jones | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.