HTML: <input class = "remark" type = "text" maxlength = "500"> JS: var $remarkInput = $('.remark'); $remarkInput.on('change',function(){ var regC = /[^ -~]+/g; var str = $(this).val(); if (regC.test(str)){ var value = s
方法如下: //在一个字符串中截取前面部分文字,汉字.全角符号按2个占位,数字英文.半角按一个占位,未显示完的最后加入“……”. //适合多行显示. function suolve(str, sub_length) { // var = 80 ; if (str == "" || str == null) return ""; var temp1 = str.replace(/[^\x00-\xff]/g, "**"); //精髓 var tem