Hello Magento Friends,

I am here with another solution for you, How to Apply Validation on Backend Customer Custom Field in Magento 2.

To fulfill orders in the best possible way and personalize the shopping experience, Magento store owners require additional information from customers. For this, you need to create a custom customer attribute. But it is also necessary to validate the input of custom customer attributes in order to avoid wrong information.

Here are the steps for How to Apply Validation on Backend Customer Custom Field in Magento 2.

Steps to Apply Validation on Backend Customer Custom Field in Magento 2:

Step 1:  First we need to create our custom customer attribute so we need to add the InstallData.php file in the following path

app\code\Vendor\Extension\Setup\InstallData.php

And add the below code

Step 2: Now you need to create di.xml in the following path.

app\code\Vendor\Extension\etc\di.xml

Then add the code as follows

Step 3: Now you need to create EavValidationRules.php in the following path

app\code\Vendor\Extension\Plugin\EavValidationRules.php

And add the below code

Conclusion:

Hence, this way you can Apply Validation on Backend Customer Custom Field in Magento 2.

Related Articles,

If you face any difficulty, share with me via the comment box and I will help you out with it. Share the article with your developer group. Stay in touch with us!

Happy Coding!

Click to rate this post!
[Total: 2 Average: 5]