As far as I know it is only possible in the microflow with help of Trim function. In the authentication Tex box we don't have the event option. So, you have to change normal text Box.
Within the properties of the Text box, on the tab Events, there is this On Leave. you can set this to call Mircoflow and have that Microflow run the Trim function.
Note! in order to have the Trim function available, make sure you download and install Module Community commons from the marketplace.
Good luck with it,