开发者

Contenteditable attribute

How can I configure max开发者_运维技巧imum number of rows in contenteditable attribute? I want to stop use after they will reach his capacity of characters for send in POST method.

I'm just using HTML 5. It's a new atributte, you can google it. It's value can be true or false. Contenteditable is not using windows enccoded new lines like: \r\n, but using creating divs and adding <br> tags to it.


You could just run some JavaScript on the element, like so:

function check_len(){
    //disable editing, or something here
    if (element.innerHTML.length >= POST_limit)
        alert('you have reached the post limit');
}

And you could attach it to a keyup handler

element.addEventListener('keyup',check_len,false);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜