Categories
CMS Magento Mastering Development

Address Validation in checkout page in Magento 2

I want to validate street address line 1 & 2 with maximum 40 character and without special character. I am using below code for this but it’s not working for me. etc/di.xml <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:ObjectManager/etc/config.xsd”> <type name=”Magento\Checkout\Block\Checkout\LayoutProcessor”> <plugin name=”add-street-field” type=”X\Y\Model\Checkout\LayoutProcessorPlugin” sortOrder=”1″/> </type> </config> Model\Checkout\LayoutProcessorPlugin.php public function afterProcess( \Magento\Checkout\Block\Checkout\LayoutProcessor $subject, array $jsLayout ) { $jsLayout[‘components’][‘checkout’][‘children’][‘steps’][‘children’][‘shipping-step’][‘children’] [‘billingAddress’][‘children’][‘shipping-address-fieldset’][‘children’][‘street’] […]

Categories
CMS Magento Mastering Development

Checkout custom shipping address field – set as required

I have created a custom module that adds a text field in shipping address. It’s workin ok but I’d like to make it required. How can I do that? I tried adding ‘required-entry’ => true at validation parameter, in file Plugin/Checkout/LayoutProcessor.php but it didn’t work. Here are the module files: Mymodules/FieldCheckout/registration.php <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, ‘Mymodules_FieldCheckout’, […]