Removes all spaces from the left and right sides of a character expression, and collapses all mutliple internal spaces to a single space.
JSV_shrinkWhitespace(expS)
expS.shrinkWhitespace()
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.
The shrinkWhitespace functions use the following arguments.
Argument | Description |
expS | The string to be shrunk. |
n/a
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
Copyright © 1998-2002 Roaring Fork Software. All rights reserved.