UE插件 寫文本提示字數限制


$().ready(function () {

var editor = UE.getEditor('editor', {
wordCount:true, //是否開啟字數統計
maximumWords:10, //允許的最大字符數
});

editor.addListener( 'contentChange', function( ) {
var str = editor.getContentTxt();
var leng = str.length;
if (leng > 200){
util.winAlert("錯誤,最多輸入兩百字");
}
});

});
傳過去之后利用strlen()函數發現字數仍然比預期的多,這是因為字符串中有html標簽,利用strip_tags();去除字符串的html標簽,就對了。(UTF-8編碼下的中文字符是3個字節)


參考文檔: https://ueditor.baidu.com/doc/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM