The question says it all; JS doesn\'t seem to have a native trim() method.
Actually, with jQuery this seems to be the way:
jQuery.trim(string)
(Reference)