Updated.
on a second thought, I don't want the server to remove any spaces since the UI is already checking for invalid entry, which is much more user friendly.
Though I think it is appropriate to trim leading and trailing spaces from the input (UI should also prevent leading and trailing spaces).