This function removes the spaces from the string value. It removes from both the side and then returns the updated value.
function Trim(sInString)
{
sInString = sInString.replace( /^\s+/g, "" );// strip leading
return sInString.replace( /\s+$/g, "" );// strip trailing
}