This question is locked. New answers and comments are not allowed.
Hi Team,
I am using below function for radetiro maxlength chack on type and paste ,it is working fine for type but not for paste. I am using getvalue method to get the content of radeditor after paste but this method gives content like (<P><Font>This is the real text</Font></P>) so how can i get the complete text .There is one method gettext() but this method doesnt give complete text of radeditor . I have tried different method getTextarea(),getcontent(),getcontentarea() but end up with no solution. Please provide me solution for that.
function isAlphaNumericKey(keyCode) {
if ((keyCode > 47 && keyCode < 58) || (keyCode > 64 && keyCode < 91)) {
return true;
}
return false;
}
function LimitCharacters(editor) {
var maxTextLength = editor._maxTextLength;
var messageText = 'Please enter characters less than or equal to ' + editor._maxTextLength + '.';
editor.attachEventHandler("keydown", function (e) {
e = (e == null) ? window.event : e;
if (isAlphaNumericKey(e.keyCode)) {
textLength = editor.get_text().length;
if (textLength >= maxTextLength) {
alert(messageText);
e.returnValue = false;
editor.setFocus();
return false;
}
}
});
}
function CalculateLength(editor, value) {
var textLength = editor.get_text().length;
var clipboardLength = value.length;
textLength += clipboardLength;
return textLength;
}
function OnClientPasteHtml(editor, args) {
debugger;
var commandName = args.get_commandName();
var value = args.get_value();
var maxTextLength = editor._maxTextLength;
var messageText = 'Please paste characters less than or equal to ' + editor._maxTextLength + '.';
if (commandName == "PasteFromWord"
|| commandName == "PasteFromWordNoFontsNoSizes"
|| commandName == "PastePlainText"
|| commandName == "PasteAsHtml"
|| commandName == "Paste") {
var textLength = CalculateLength(editor, value);
var textLength2 = editor.get_text().length;
var originalText = editor.get_text() + value;
var requiredLength = maxTextLength - textLength2;
var strippedContent = value.replace(/\<img .+?\>/ig, "");
if (textLength2 == maxTextLength) {
alert(messageText);
var strippedContent = value.replace(/\<img .+?\>/ig, "");
var contentReal = (originalText.substring(0, maxTextLength));
args.set_value(contentReal);
args.set_cancel(true);
}
if (requiredLength != 0) {
var contentReal = (value.substring(0, requiredLength));
args.set_value(contentReal);
}
}
}
Thanks,
Noble Kurian
I am using below function for radetiro maxlength chack on type and paste ,it is working fine for type but not for paste. I am using getvalue method to get the content of radeditor after paste but this method gives content like (<P><Font>This is the real text</Font></P>) so how can i get the complete text .There is one method gettext() but this method doesnt give complete text of radeditor . I have tried different method getTextarea(),getcontent(),getcontentarea() but end up with no solution. Please provide me solution for that.
function isAlphaNumericKey(keyCode) {
if ((keyCode > 47 && keyCode < 58) || (keyCode > 64 && keyCode < 91)) {
return true;
}
return false;
}
function LimitCharacters(editor) {
var maxTextLength = editor._maxTextLength;
var messageText = 'Please enter characters less than or equal to ' + editor._maxTextLength + '.';
editor.attachEventHandler("keydown", function (e) {
e = (e == null) ? window.event : e;
if (isAlphaNumericKey(e.keyCode)) {
textLength = editor.get_text().length;
if (textLength >= maxTextLength) {
alert(messageText);
e.returnValue = false;
editor.setFocus();
return false;
}
}
});
}
function CalculateLength(editor, value) {
var textLength = editor.get_text().length;
var clipboardLength = value.length;
textLength += clipboardLength;
return textLength;
}
function OnClientPasteHtml(editor, args) {
debugger;
var commandName = args.get_commandName();
var value = args.get_value();
var maxTextLength = editor._maxTextLength;
var messageText = 'Please paste characters less than or equal to ' + editor._maxTextLength + '.';
if (commandName == "PasteFromWord"
|| commandName == "PasteFromWordNoFontsNoSizes"
|| commandName == "PastePlainText"
|| commandName == "PasteAsHtml"
|| commandName == "Paste") {
var textLength = CalculateLength(editor, value);
var textLength2 = editor.get_text().length;
var originalText = editor.get_text() + value;
var requiredLength = maxTextLength - textLength2;
var strippedContent = value.replace(/\<img .+?\>/ig, "");
if (textLength2 == maxTextLength) {
alert(messageText);
var strippedContent = value.replace(/\<img .+?\>/ig, "");
var contentReal = (originalText.substring(0, maxTextLength));
args.set_value(contentReal);
args.set_cancel(true);
}
if (requiredLength != 0) {
var contentReal = (value.substring(0, requiredLength));
args.set_value(contentReal);
}
}
}
Thanks,
Noble Kurian