The reason why
I’m sure everybody, one day, passed through this problem. And to fix it, you need to develop your own trimming functionality or use a library like jQuery for example.
UPDATE: Newer versions of Safari will do the trim automatically.
jQuery defines a trim function that you can use like this:
$.trim(" test ")
And here is the implementation of this function (inside jQuery):
.toString().replace(/^\s+/, "").replace(/\s+$/, "")
So you can use that for Safari, here’s an example of its use: