1

In my magento setup I am not able to insert special characters for customer First name and Last name.

The Input Validation for Customer Attribute First Name and Last Name is NONE. But still Magento 2 not allowing me to insert special characters for customer First name and Last name.

I also checked in a fresh magento 2 installation setup and there I am able to insert special characters.

Please help. I am using Magento 2.4.2

Customer Attribute configurations:

enter image description here

Frontend - Create Account:

enter image description here

1
  • Hi Kaushik did you find the solution ? Commented Dec 22, 2021 at 13:39

2 Answers 2

6

In \Magento\Customer\Model\Validator\Name::isValidName

Magento matches the first name of the customer with the regex pattern

private const PATTERN_NAME = '/(?:[\p{L}\p{M}\,\-\_\.\'\s\d]){1,255}+/u';

 /**
 * Check if name field is valid.
 *
 * @param string|null $nameValue
 * @return bool
 */
private function isValidName($nameValue)
{
    if ($nameValue != null) {
        if (preg_match(self::PATTERN_NAME, $nameValue, $matches)) {
            return $matches[0] == $nameValue;
        }
    }

    return true;
}
1
-2

where can I find \Magento\Customer\Model\Validator\Name::isValidName to edit the private const PATTERN_NAME?

Regards

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.