0

I want to set the maximum length of character for my texteditor. Users will enter text in Iframe in the editor. I am getting the characters through the keydown event. I get the "maxlength" by calculating length with text & maxlength and by setting keyflag as false.

My problem is that I now have to allow the user to edit text when user press backspace, delete, ctrl+special keys.

Is there any other general ways to achieve the maxlength property?

4

2 回答 2

0

一旦达到最大限制,您可以执行以下操作

var text = $('#editor').text().substring(0,maxlength);

可以作为值添加到编辑器中的文本

于 2013-04-24T06:02:23.737 回答
0

兄弟们,我终于做到了。。

在 keyDown 事件和使用键码我们可以实现这些功能......

keydown(e)
{
 if(e.keyCode==8) //for backspace key
{
 // your code
}
}

同样我们可以编写我们需要的函数

于 2013-04-26T05:55:08.690 回答