i'd just use popcorn's method, but it might be better if spaces are removed automatically after the entry is made. i wouldn't try any "realtime" whitespace prevention or removal
and yes, doing practically any sort of text manipulation on an edit box sends the caret to the beginning of the edit box (which i have found extremely annoying in cases)
