Is there any way to limit the number of lines (not character length) in a textbox?
2 Answers, 1 is accepted
0
Dimo
Telerik team
answered on 19 Dec 2008, 08:37 PM
Hello Scott,
I am not sure what do you mean by "number of lines" - is it the number of carriage returns (created by pressing the Enter key) or the number of places where the input string splits to a new line? I am not aware of a way to count the second number, however, I can research this if needed.
However, if you want to count the number of carriage returns, you can try using some Javascript. Please subscribe to the RadTextBox' OnKeyPress client event, get the current value of the textbox and count the new lines. For example:
[Javascript]
var newLines = 0;
for (var j = 0; j < textboxvalue.length; j++)
{
if (textboxvalue.charCodeAt(j) == 10)
{
newLines++;
}
}
All the best,
Dimo
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.