Javascript String Length Differs From PHP mb_strlen

Posted by TheOnly92 on Stack Overflow See other posts from Stack Overflow or by TheOnly92
Published on 2010-03-20T12:00:16Z Indexed on 2010/03/20 12:11 UTC
Read the original article Hit count: 382

Filed under:
|

I use document.getElementById("text").value.length to get the string length through javascript, and mb_strlen($_POST['text']) to get the string length by PHP and both differs very much. Carriage returns are converted in javascript before getting the string length, but I guess some characters are not being counted.

For example,

[b]15. Umieszczanie obrazka z logo na stronie zespolu[/b]

This block of text is calculated 57 in javascript and 58 in PHP. When the text gets long, the difference increases. Is there any way to overcome this?

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript