Removes all spaces from the left and right sides of a character expression, and collapses all mutliple internal spaces to a single space.

Syntax

JSV_shrinkWhitespace(expS)

Prototype

expS.shrinkWhitespace()

Returns

The shrinkWhitespace functions returns the specified expression with spaces removed from both sides of the string and all multiple occurrences of spaces with a single space.

Parameters

The shrinkWhitespace functions use the following arguments.

Argument Description
expS The string to be shrunk.

Remarks

n/a

Dependencies

JSV_trimAll, JSV_splitString

Example

The following lines of code

<form action="shrinkWhitepace.html" name="ShrinkForm" id="ShrinkForm">
<input type="text"
       name="TextField"
       id="TextField"
       value="       Busy    as    a beaver            "
       size="40"
       maxlength="128">
  
<input type="button" 
       name="btnShrink"
       id="btnShrink"
       value="Shrink"
       class="jsvButtons"
       onClick="shrinkTest();">
<input type="Reset" class="jsvButtons">
</form>

<script type="text/javascript" language="JavaScript">
document.ShrinkForm.TextField.focus();

function shrinkTest() {
    document.ShrinkForm.TextField.value = 
        document.ShrinkForm.TextField.value.shrinkWhitespace();
}
</script>

produce