This is a migrated thread and some comments may be shown as answers.

maxlength javascript vs. .net

2 Answers 88 Views
Input
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 19 Aug 2013, 07:37 PM
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 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 22 Aug 2013, 07:15 AM
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.
0
Peter
Top achievements
Rank 1
answered on 22 Aug 2013, 12:53 PM
Thank you that information is GREAT!  But I will wait until the hotfix is part of an official service pack or Q3.
Tags
Input
Asked by
Peter
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Peter
Top achievements
Rank 1
Share this question
or