Here is a simple answer.
idea is from This GitHub Repo
Chinese and English aren't counted in the same way,if you count it by byteLength , you will find that chinese is 2 times of english
you can try code below .
/*useByteLength
function checkTextLength($element) {
txtCount = $element.val().replace(/[^\x00-\xff]/g, "pp").length +
($element.val().match(/\n/g) || []).length;
return txtCount;
}
if your condition need to count Chinese and English in the same way , you can try this.
/*count Chinese and English in the same way
function checkTextLength($element) {
txtCount = $elements.val().length + ($elements.val().match(/\n/g) || []).length;
return txtCount;
}