take into consideration the number of new lines when deciding whether MaxLength has been reached.
I have updated your Telerik points for bringing the issue to our attention.
Now, here are some hints on your questions:
In order to count the number of characters and exclude line breaks, you can use the following:
<telerik:RadTextBox ID="RTB1" runat="server" TextMode="MultiLine" ClientEvents-OnKeyPress="KeyPress
if ($telerik.isIE || args.get_domEvent().rawEvent.keyCode == 0 || args.get_domEvent().rawEvent.keyCode == 13) // 13 : Enter key
text = escape(sender.get_value() + args.get_keyCharacter());
text = escape(sender.get_value());
while (text.indexOf("%0D%0A") != -1) // IE
text = text.replace("%0D%0A", " ");
while (text.indexOf("%0A") != -1)
text = text.replace("%0A", " ");
while (text.indexOf("%0D") != -1)
text = text.replace("%0D", " ");
var calculatedLength = unescape(text).length;
if (args.get_domEvent().rawEvent.keyCode == 8 && calculatedLength > 0) // 8 : backspace
calculatedLength -= 1;
document.title = calculatedLength;
work correctly in Internet Explorer, because this browser behaves differently, when it comes to pressing of non-alphanumeric keys (as you have already observed). You can't use KeyPress, however, you can use the keydown
event. It is not exposed in the control's API, but you can still subscribe to it like this:
<telerik:RadTextBox ID="RTB1" runat="server" TextMode="MultiLine" onkeydown="KeyDown(event)"
// e.keyCode == 8 : backspace
// e.keyCode == 46 : delete
As a conclusion, you will have to use some combination of both methods in order to achieve some nice cross-browser solution (as always :) ).
the Telerik team
Check out Telerik Trainer
, the state of the art learning tool for Telerik products.