Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
04-20-2013, 09:00 PM #1
- Join Date
- Apr 2013
- Thanked 0 Times in 0 Posts
TextArea Validation with Word Wraps
i have a text area with max length of 250 and the text area must have allow only 50 characters in each of the 5 lines. if a particular word is not coming fully in the 50 characters it can wrap to the next line. so i may not be using the full 50 character space in each of the 5 lines.
Question: how do i achieve it. I want to count the number of rows by identifying the rows(with new line or by word wrap if the word gets wraped or by new line if it does not) then if he has reached 5 rows though he can type more character out of 250 he should not be able to go to the next line. Can some one pls provide your suggestions.
oArea = document.getElementById('txtAreaId');
var aNewlines = oArea.value.split("\n,\r");
var iNewlineCount = aNewlines.length;
<td ><textarea name="txtArea" id="txtAreaId" COLS="50" ROWS="5" WRAP="HARD" class="REQUIRED" style="width: 100%;" onkeypress="return
04-20-2013, 11:12 PM #2
- Join Date
- May 2002
- Hayward, CA
- Thanked 24 Times in 22 Posts
This question's in the wrong forum - Post a JS is supposed to be for completed, working scripts. I'm interested in a solution, though - anytime text processing comes up, I want to know about the algorithm used to handle it... so I'll watch. Sorry I couldn't help outright.
04-21-2013, 02:49 AM #3
I'm not sure what your final project is trying to accomplish,
but I'm pretty sure you won't get there with that code.
when words are typed continuously.
You can see this (if using FF) by expanding the area with a mouse click
on the lower right corner of the textarea.