jsUtils.trim()

Trims string variable.

jsUtils.trim( str )
  str - string variable

Returns trimmed string.

JavaScript does not have a function that trims white spaces from the beginning and end of a string. jsUtils.trim() should compensates for the lack. Besides white spaces, it will also remove new line codes if they are at the beginning or end of the string.

Example

<!DOCTYPE html>
<html>
<head>
    <script src="system/libs/jsUtils.js" type="text/javascript"></script>
    <script type="text/javascript">
        window.onload = function() {
            alert(jsUtils.trim(' some string.     '));
        }
    </script>
<body>
</body>
</html>

See Also