By Pat Cahill on Aug 15, 2002
This script strips excess spaces and non-printing characters from a field. Users sometimes enter ” ” in required fields to trick most validation that only checks for “” length fields. This script takes a string and removes the leading and trailing spaces and also any extra spaces in the string. Works in MSIE Only.
String to strip excess spaces from:

Try 8 blank spaces
or try this string
or try this string

The JavaScript Source: Page Details: remove_XS_whitespace

Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!