Question

The iPad application I'm working on requires that the user provide a username and password that are authenticated against a server before they can enter the application proper. I'm considering making a subtle change so that whitespace at the start and end of the username and password are silently ignored.

Good idea? Bad idea? Reasons for your position?

This has come about after I demonstrated the product to a customer today and struggled to log in. After three attempts I finally realised that I'd somehow managed to put a space before my username, and of course, that didn't match any username on the server. There's a very, very subtle difference in width with an additional space at the start of a text field on the iPad, given that the field border is spaced away from the first character anyway, and it took me some time to notice.

Was it helpful?

Solution

I think that it is a good practice to trim the whitespaces, since they are usually considered invalid username/password symbols (users can miss them very easily, especially if they use more than one).

NSString *trimmedString = [myString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top