How to Enable Phone Number Validation in Magento 2 Commerce?

Today, we’re going to enable phone number verification in Magento 2 Commerce.

Unlike Magento 2 Open Source, Magento 2 Commerce comes with a built-in feature that lets you create new custom fields and add them to various places such as Registration, Checkout, and Customer Account Edit forms.

And the best part is, you can easily use this built-in feature to collect & validate the phone numbers of your customers in your Magento 2 store.

In this post, we will show you exactly how to enable phone number verification in your Magento 2 Commerce-based eCommerce store.

Step-By-Step Process to Enable Phone Number Verification in Magento 2 Commerce

Please follow the below steps to learn how to enable phone verification in Magento 2 Commerce.

Step - 1

First of all, log in to your admin panel, navigate to Stores > Attributes > Customer, and click on the Add New Attribute button.

Step - 2

After that, expand the Attribute Properties section and do the following:

  • Write a label to identify the attribute in the Default Label field.
  • Write a code to identify the attribute in the Attribute Code field.
  • Select an input type of your choice in the Input Type field.
  • Select YES or NO in the Values Required field.
  • Write a default value if you want to in the Default Value field.
  • Select a type of validation for input in the Input Validation field.

Step - 3

Next, expand the Customers Grid and Segment Properties section and do the following:

  • Select YES or No as per your needs in the Add to Column Options field.
  • Select YES or No as per your needs in the Use in Filter Options field.
  • Select YES or No as per your needs in the Use in the Search Options field.
  • Select YES or No as per your needs in the Use in Customer Segment field.

Step - 4

Now, go to the Storefront Properties section and do the following:

  • Select YES in the Show on Storefront field.
  • Mention a sort order if you want to in the Sort Order field.
  • Select a form where you’d like to apply validation in the Forms to Use Infield.

Step - 5

Lastly, click on the Save Changes button to finish the process.

Final Note

And there you go!

This is the best & easiest way to enable phone number verification in Magento 2 Commerce.

And if you need our professional assistance with your Magento 2 Development project, feel free to contact us at any time.