I use document.getElementById(\"text\").value.length to get the string length through javascript, and mb_strlen($_POST[\'text\']) to get the string
document.getElementById(\"text\").value.length
mb_strlen($_POST[\'text\'])
This should do the trick
function mb_strlen (s) { return ~-encodeURI(s).split(/%..|./).length; }