how to achieve trimming space as you type in a textfield