Hi
Using professional version 1.5
I’m using a textarea(txt) and wanted to limit the number of characters entered into this field i have tried:
if (cInd==1) {
if (stage==1) {
this.obj.onpaste = function(e) {
e = e||window.event;
var currentLength = e.srcElement.value.length;
var selectionLength = document.selection.createRange().text.length;
var clipBoardLength = window.clipboardData.getData(“Text”).length;
if(currentLength - selectionLength + clipBoardLength > 250) {
return false;
}
};
this.obj.onkeypress = function(e){
e = e||window.event;
var currentLength = e.srcElement.value.length;
var selectionLength = document.selection.createRange().text.length;
if(currentLength - selectionLength >= 250) {
return false;
}
};
}
}
but the onkeypress doesn’t seem to fire?
thanks again
cliff
The textarea, used as editor ( txt ), attached to the document.body, so all events key events go directly to the document.body and can’t be catch on this.obj element.
You can use
if (cInd==1) {
if (stage==1) {
this.editor.obj.onkeypress = function(e){
In such case, it will be attached directly to textarea
OK i had to use
this._fake.editor.obj.onkeypress
and
this._fake.editor.obj.onpaste
Because the field was on the left side split in a grid.
Thanks for pointing me in the right direction.
c
Code:
if (cInd==1) {
if (stage==1) {
this._fake.editor.obj.onkeypress = function(e){
e = e||window.event;
var currentLength = e.srcElement.value.length;
var selectionLength = document.selection.createRange().text.length;
if(currentLength - selectionLength >= 250) {
return false;
}
};
this._fake.editor.obj.onpaste = function(e){
e = e||window.event;
var currentLength = e.srcElement.value.length;
var selectionLength = document.selection.createRange().text.length;
if(currentLength - selectionLength >= 250) {
return false;
}
};
}
}