I sometimes have messages from users saying that they can't log in. Most often I have found it's because they inadvertently added a space either before or after their email.
Is it a good idea to automatically strip spaces from emails on log in or on any form entry?
$email =~ s/\s//g; #strip all spaces out
This topic will answer most of your questions. I'm putting bellow a brief summary:
Emails/Usernames: I agree with Rajwanshi, as spaces are not a valid character in emails, there is no harm in removing them. In the company I'm working for, we had the same problem that you are describing and removing all spaces turned out to be a good solution.
Passwords: As they say here, you shouldn't trim or modify them in any way. Just hash them as is.
Other text inputs: I would say to act depending on the context. But if you decide to trim, I would advise to do it on submit as it would not bring a good user experience to use online validation and bother users with an ending space.
Hope it will help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With