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

**URL:** <https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616>\
**Category:** Get Help\
**Tags:** validation, login\
**Created:** [April 12, 2022, 2:37pm UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616 "2022-04-12T14:37:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiny.lionel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shiny.lionel/32/33837_2.png) [@shiny.lionel](https://community.auth0.com/u/shiny.lionel)\
**Post date:** [April 12, 2022, 2:37pm UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616/1 "2022-04-12T14:37:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 13, 2022, 12:12am UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616/3 "2022-04-13T00:12:12Z")

</div>

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](https://manage.auth0.com/#/connections/database) on the settings page.

 ![image](https://global.discourse-cdn.com/auth0/original/3X/b/2/b2d9dc8fe3c73f614264490ff3ba314ded975307.png)

See [here](https://auth0.com/docs/authenticate/database-connections/require-username#username-length) to learn more about the Username Length.

Moreover, Auth0 also checks for these [Allowed Characters](https://auth0.com/docs/authenticate/database-connections/require-username#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.

---

<div class="post-metadata">

**Author:** ![shiny.lionel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shiny.lionel/32/33837_2.png) [@shiny.lionel](https://community.auth0.com/u/shiny.lionel)\
**Post date:** [April 19, 2022, 6:13am UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616/4 "2022-04-19T06:13:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [April 19, 2022, 10:56pm UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616/5 "2022-04-19T22:56:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![shiny.lionel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/shiny.lionel/32/33837_2.png) [@shiny.lionel](https://community.auth0.com/u/shiny.lionel)\
**Post date:** [April 21, 2022, 3:58am UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616/6 "2022-04-21T03:58:28Z")

</div>

![LoginSettings](https://global.discourse-cdn.com/auth0/original/3X/e/8/e8228ceca3d5242eb342e08301282306ae0bcc32.png)  
 ![EnterpriseConnections](https://global.discourse-cdn.com/auth0/original/3X/b/2/b29675643095abd0428db61c65715796e3b89b9a.png)

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

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 21, 2022, 3:27pm UTC](https://community.auth0.com/t/how-to-add-validations-on-the-username-userid-field-on-the-login-page/81616/7 "2022-12-21T15:27:23Z")

</div>


