Limit Textbox number of lines

3 posts, 0 answers
  1. Scott
    Scott avatar
    45 posts
    Member since:
    Apr 2008

    Posted 19 Dec 2008 Link to this post

    Is there any way to limit the number of lines (not character length) in a textbox? 
  2. Dimo
    Admin
    Dimo avatar
    8330 posts

    Posted 19 Dec 2008 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Scott
    Scott avatar
    45 posts
    Member since:
    Apr 2008

    Posted 19 Dec 2008 Link to this post

    Yes, I was thinking more of carriage return.  I'll give your code a try and thank you for the response.
Back to Top