Username: Ignore whitespace and case

Right now on a user login it requires username to be case sensitive and no white spaces. Unfortunately some auto fill and mobile devices like to capitalize the first character of a username. Is there a way to ignore case sensitivity and whitespaces at end of username?

You just have to use a lowercase formatter whenever you're accessing the username variable :wink:

Edit: For whitespace there should be a trim formatter, alternatively a string replace formatter with to find empty spaces and replace with an empty string

But that doesn't help if the username in the DataBase actually has capitals?

I had the same problem, I had to come up with some SQL to convert everyone to lowercase. Once that's done I started using the lowercase formatter on the login form. Nice idea about removing the whitespace!

You could create a Server Action to loop through all users and replace each username with the lowercase version.

Do the same for emails...

5 Likes

How about creating a generated column that is the lowercase of the username?

On iOS you can prevent the auto-capitalization like:

<input name="username" autocapitalize="none">

Supported Attributes (apple.com)

Better Form Inputs For Better Mobile User Experiences | CSS-Tricks

2 Likes

Try this SQL (backup the database first!)

UPDATE users
SET username = LOWER(REPLACE(username, ' ', ''));

Obviously change the table and field names to match your data.