Trim function in PHP can remove whitespace from the beginning and end of a string.
Javascript do not have this function, but is easy to made one.
// remove space in a string
function trim(str)
{
if(!str || typeof str != 'string')
return null;
return str.replace('/^\s+|\s+$/g', '');
}
