- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019
07:29 AM
04-18-2019
07:29 AM
Add custom validator on region in checkout page
I can successfully add validation on the company, phone, street fields. But when I apply that to the region field, it doesn't work anymore. In other words, I get no validation message at all, I can write whatever I want in the region field and I get no red message.
checkout_index_index.xml
<?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"> <body> <referenceBlock name="checkout.root"> <arguments> <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"> <!-- To affect the shipping address fields --> <item name="shipping-address-fieldset" xsi:type="array"> <item name="children" xsi:type="array"> <item name="region" xsi:type="array"> <item name="validation" xsi:type="array"> <item name="max_text_length" xsi:type="number">30</item> <item name="required-entry" xsi:type="boolean">true</item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </item> </argument> </arguments> </referenceBlock> </body>
Appreciate your help. Thanks!
If issue solved, click Kudos/Accept as solutions.
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019
09:48 PM
04-18-2019
09:48 PM
Re: Add custom validator on region in checkout page
Region field have more complex logic and depends to country settings.
You can specify region is required for each country. You can do that from admin panel.
You can specify region is required for each country. You can do that from admin panel.