How to add validations on the username/userid field on the login page

We would like to add validations on the username like length, if it can be alphanumeric etc on the login page. Please provide options/ APIs for the same.

Hi @shiny.lionel,

Thanks for reaching out to the Auth0 Community!

I understand that you would like to add validations on the username property when the user signs up on the login page.

Behind the scenes, Auth0 performs username validations whenever a user signs up with the Requires Username enabled in the Database connection.

By default, the allowed length for usernames is between 1 and 15 characters. However, you could modify the length minimum and maximum value (up to a maximum length of 128 characters) by going to your Auth0 Dashboard > Authentication > Database > YOUR_DB on the settings page.

See here to learn more about the Username Length.

Moreover, Auth0 also checks for these Allowed Characters in the username when signing up. If the username does not use the allowed characters, then the user will not be allowed to sign up.

Hoped this helps!

Please let me know if there’s anything else I can do to help.

Thank you.

Hi @rueben.tiow ,

Thank you for the information.
Can these same validations be set on Enterprise Connections? We are using Enterprise connections too for authentication; hence please clarify.

Thanks,
Shiny

Hi @shiny.lionel,

Thank you for your response.

First, let me clarify that the Requires Username is a Database feature. That is where the username validations happen.

With that said, could you please elaborate if you are retrieving the username from the Enterprise Connection?

If that is the case, you may need to perform the username validation during the authentication flow.

I am looking forward to your reply.

Thanks.


Hi @rueben.tiow,

Yes, we use ‘Active Directory / LDAP’ feature for Authentication. Few of our applications authenticate against our company’s Active Directory and other few against our LDAP.

While the user clicks submit button on the login page, I would like to verify if the username contains only numbers and if the length is exactly 9. Our usernames are supposed to be 9 digit numbers.

I have attached snapshots of our settings for better understanding. Please review and let me know your thoughts.

Thanks,
Shiny