I had an order with the details in Russian characters, so I'd like to block the forms to Alphabetic characters only, I thought that it would be native in Magento 2.

Magento 2 Russian characters in checkout

How could I an user-friendly method to avoid Russian (Persian, etc) characters in my store?


Use a Regex range that covers all the Cyrillic unicode ranges:

let pattern = /[\u0400-\u04FF]/;
if (pattern.test("John ПотоцкаяЛ Wick")) console.log("cyrillic; not accpted");
else console.log("not cyrillic; accepted");

This validation allows you to block all the Rusian alphabets.

If you only want to accept English alphabets, then use the following Regex:

var letterNumber = /^[a-zA-Z]+$/;

Add the required validation to the checkout form.

Refer these links to do the same:

  1. https://aureatelabs.com/magento-2/add-custom-validation-rule-in-magento-2/
  2. https://www.mageplaza.com/devdocs/add-custom-validations-before-placing-order-magento-2.html
  3. https://devdocs.magento.com/guides/v2.3/howdoi/checkout/checkout_order.html

Comment if you need help in adding the validation.

Hope this helps.


To just accept alphanumeric characters, letters from A to Z, numbers space and underscore, you can add an XML file that implements the validation in your checkout.


In this file, I added the alphanumeric validation to the company field.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <referenceBlock  name="checkout.root">
                    <argument name="jsLayout" xsi:type="array">
                        <item name="components" xsi:type="array">
                            <item name="checkout" xsi:type="array">
                                <item name="children" xsi:type="array">
                                    <item name="steps" xsi:type="array">
                                        <item name="children" xsi:type="array">
                                            <item name="shipping-step" xsi:type="array">
                                                <item name="children" xsi:type="array">
                                                    <item name="shippingAddress" xsi:type="array">
                                                        <item name="children" xsi:type="array">
                                                            <item name="shipping-address-fieldset" xsi:type="array">
                                                                <item name="children" xsi:type="array">
                                                                    <item name="region_id" xsi:type="array">...</item>
                                                                    <item name="postcode" xsi:type="array">...</item>
                                                                    <item name="company" xsi:type="array">
                                                                        <item name="validation" xsi:type="array">
                                                                            <item name="min_text_length" xsi:type="number">0</item>
                                                                            <item name="max_text_length" xsi:type="number">9</item>
                                                                            <item name="alphanumeric" xsi:type="boolean">true</item>
                                                                            <item name="required-entry" xsi:type="boolean">true</item>
                                                                    <item name="fax" xsi:type="array">...</item>
                                                                    <item name="country_id" xsi:type="array">...</item>
                                                                    <item name="telephone" xsi:type="array">...</item>

If you wanna see all the possible validations you can check here.

Magento 2 JS validations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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