Cold Fusion Tips-N-Tricks
Javascript: Trimming form fields

This function simulates the CF Trim( ) function.



Example HTML/CFML code:
function trim(thisString){
	var newString = thisString;
	while (newString.charCodeAt(0) < 33)
	{
		newString = newString.substring(1,newString.length);
	}
	
	while (newString.charCodeAt(newString.length - 1) < 33)
	{
		newString = newString.substring(0, newString.length - 1);
	}
	return newString;
}


Return to the Cold Fusion Tips-N-Tricks topic list