I found Javascript from the search site function which enables me to check the number of characters when I paste.
Unfotunately, it doesn't work!
The javascript is below, and the ClientExecutedCommand function is fired on "OnClientCommandExecuted":
The HTML:
The problem is that line 12 args.get_value() of the Javascript returns null although I have contents in my clipboard and I can see that when I paste in to Notepad there is something there.
Does anyone have any ideas?
Thanks
R
Unfotunately, it doesn't work!
The javascript is below, and the ClientExecutedCommand function is fired on "OnClientCommandExecuted":
| <script type="text/javascript"> | |
| function CalculateLength(editor, value) { | |
| var textLength = editor.get_text().length; | |
| var clipboardLength = value.length; | |
| textLength += clipboardLength; | |
| return textLength; | |
| } | |
| function ClientExecuteCommand(editor, args) { | |
| var commandName = args.get_commandName(); | |
| var value = args.get_value(); | |
| if (commandName == "PasteFromWord" | |
| || commandName == "PasteFromWordNoFontsNoSizes" | |
| || commandName == "PastePlainText" | |
| || commandName == "PasteAsHtml" | |
| || commandName == "Paste") { | |
| var textLength = CalculateLength(editor, value); | |
| if (textLength >= 10) { | |
| alert("Max char. reached"); | |
| args.set_cancel(true); | |
| } | |
| } | |
| } | |
| </script> |
The HTML:
| <telerik:RadEditor ID="RadEditor1" runat="server" OnClientCommandExecuted="ClientExecuteCommand"> | |
| <Content> | |
| </Content> | |
| </telerik:RadEditor> |
The problem is that line 12 args.get_value() of the Javascript returns null although I have contents in my clipboard and I can see that when I paste in to Notepad there is something there.
Does anyone have any ideas?
Thanks
R
