How to add 0 prefix on Universal login sms

2021-09-29_10-49

I want to add 0 prefix before my phone number, example: 0981***, instead of 981***
Thank to help

Hi @hai.hoang1,

Welcome to the Auth0 Community!

I understand that you’d like to prepend a 0 into the phone number when a user starts a Passwordless authentication flow.

You can prepend a 0 before the phone number by using the prefill option in your Passwordless Universal Login Page: https://auth0.com/docs/libraries/lock/lock-configuration#prefill-object-

prefill: {
  phoneNumber: "0"
}

After doing so, the phone number field will begin with 0. See below:

Please let me know if there are any questions. I’d be happy to assist.

Thank you.

Sorry, but that is not my accepted.
if user input 981*** in phone number input. Phone number will be +84981*** (valid phone number)
if user input 0981*** in phone number input. Phone number will be +840981*** (invalid phone number)
But normal user will input 0 in start off phone number.
I wan’t to remove 0 at the start, when send request to auth0 server.

Hi @hai.hoang1,

Thank you for your response.

Unfortunately, there is no way to manipulate the user’s inputted phone number before sending it to the Auth0 server. It is up to the user to submit a valid phone number to authenticate.

However, it may be worth trying to customize the error message to provide some guidance for the user to submit a valid phone number: See our documentation on customizing Lock Error Messages: https://auth0.com/docs/brand-and-customize/customize-lock-error-messages

Below is an example of how to accomplish a customized error message for invalid phone numbers during Passwordless login:

var lock = new Auth0LockPasswordless(config.clientID, config.auth0Domain, {
  languageDictionary: {
      passwordless: {
        'bad.phone_number': 'The phone number is invalid'
      },
  }
  ...
});

Hoped this helps! Please let me know if need further assistance, I would be happy to help.

Thank you.

Thank you for your response

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.