Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Steve on Dec 30, 2008 11:28
open dhtmlx forum
DHTMLEDITOR - limiting the number of characters

Hi

Using dhtmlxeditor, is it possible to limit the number of characters the user can enter?

Thanks.
Answer posted by Support on Dec 30, 2008 12:39
There is no build in solution, but you can check a possible workaround here
http://dhtmlx.com/docs/products/dhtmlxGrid/samples/cell_types/pro_maxlength.html?un=1230669513000
Answer posted by Steve on Dec 30, 2008 13:48

Thanks for the link.  I've got this but am clearly missing something as this.length.value is null or not an object.

dhtmlxEvent(editor.edDoc, "keypress", function(e){

if (this.value.length>=10) {

alert ("You have reached the maximum number of characters");

return false;

}

})

Any ideas?

Answer posted by Support on Jan 12, 2009 01:30

In case of dhtmlxEditor you can get its html content. Just for example:

dhtmlxEvent(editor.edDoc, "keypress", function(e){

var html_content = editor.getContent(); 

if (html_content.length >= MAX_LENGTH) {


alert ("You have reached the maximum number of characters");


return false;

}

})