Php trim vs. jQuery trim

I am validating that a textarea’s value is not more than 255 characters.

I am validating front end and back end before updating the database.

If the textarea value is one long string without spaces or carriage returns jQuery trim and php trim return the same string length.

But if the textarea value has spaces and / or carriage returns throughout the string, jQuery and php ( after trim() ) return different string lengths. Could anyone tell me why? Or what I can do to get more accurate validation front end and back end.

Thanks in advance.

I was not aware that jQuery trim() function gave any kind of length indication.
Which jQuery trim are you using?

The cause for your dilemma may involve the windows newlines \r
vs the linux newlines \

More info on how you currently trim things, will enable us to set up a similar development simulation on our end, so that we can test some different potential solutions.