Log in

View Full Version : textarea limitations



lord22
11-08-2009, 04:46 PM
Hi,

I have a textarea with 292px width.
1) How can I force a break-line when the text is over 292px?
2) How can I announce the user that the text is over 9 lines? (I want a limit of 9 lines)

Thanks!

davelf
11-09-2009, 03:57 AM
Got this from older post:


var maximumLength = 292;

function checkLength(control, maximum) {
var length = control.value.length;

if (length > maximum) {
alert('Please limit your message to ' + maximumLength
+ ' characters. There are currently ' + length + '.');
return false;
}
return true;
}

function validate(form) {
var controls = form.elements;

if (!checkLength(controls.textArea, maximumLength))
return false;

return true;
}




<form action="..." onsubmit="return validate(this);">
<!-- ... -->
<textarea ... onchange="checkLength(this, maximumLength);"></textarea>
<!-- ... -->
</form>


gud luck

Piotto
11-09-2009, 03:06 PM
Well i don't know how to count the 9 lines but you can wrap the text using the html tag wrap="soft" (without sending out the carriage returns) or wrap="hard" (sending out the carriage returns). I always use the soft one...

Hope this can help a bit...