maxlength javascript vs. .net

3 posts, 0 answers
  1. Peter
    Peter avatar
    71 posts
    Member since:
    Mar 2012

    Posted 19 Aug 2013 Link to this post

    Web Application using 2013.1.417.45

    We have a multi-line RadTextBox on a page.  We have the maxlength set to 250.

    Javascript appears to treat carriage returns as 1 character vs. 2 characters in .NET.   With 1 carriage return, .Net sees 251 characters when the box is completely filled.  

    Is there an option for RadTextBox to have carriage returns treated the same way as .NET?

    OR

    Is there a way to override the TEXT property globally for RadTextBox, and force a Left by the maxlength?
    -->  I would rather not have to create a control that inherits from the RadTextBox.

    Any ideas?
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 22 Aug 2013 Link to this post

    Hello Peter,

    You probably know that there is no maxlength for the textarea by the HTML specification. We had implemented our, based on the .length of the value of the textarea. The problem is that the .length can vary even in one browser, since it counts the \r\n as 2 chars and \n as one. But in the same text (if copied or set via JS) there could be both \n and \r\n.

    In their latest versions, the browsers, are starting to validating the max length, and they are counting the new line as two chars during the submit. Since it is currently more consistent, we did a fix in our RadTextBox control, and now if it is in multiline, we are also counting the new line as two characters.

    I would suggest you to get the latest hotfix and test it. It was fixed about two or tree weeks ago.

    Regards,
    Vasil
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter
    Peter avatar
    71 posts
    Member since:
    Mar 2012

    Posted 22 Aug 2013 Link to this post

    Thank you that information is GREAT!  But I will wait until the hotfix is part of an official service pack or Q3.
Back to Top