Sunday, May 13, 2007

Remove Spaces From a Text Field

This page shows you how to remove spaces from a text field. Any spaces entered by the user will be removed when they click anywhere outside the text field.

function removeSpaces(string) {
var tstring = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
tstring += splitstring[i];
return tstring;
}

No comments: