I am trying to give US format phone number validation in onepage checkout page
This is the layout checkout_index_index.xml that i created in my custom module. I know how to make i work by editing the core module (which is a strict no no when it comes to magento), Can anyone tell me what i am doing wrong .
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlockname="checkout.root">
<arguments>
<argument name="jsLayout" xsi:type="array">
<!-- Your customization will be here -->
<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="telephone" xsi:type="array">
<!--Validation for US phone number format-->
<item name="validation" xsi:type="array">
<item name="phoneUS" xsi:type="string">true</item>
</item>
<item name="config" xsi:type="array">
<item name="tooltip" xsi:type="array">
<item name="description" xsi:type="string" translate="true">For delivery questions.</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
</body>
</page>
I tried doing this by copying the entire checkout_index_index.xml page into my custom module ,which worked partially, because when i did that the shipping price disappeared.
i found this magento doc but didnt fully understand it.
Any help would be appretiated
Best Answer
Vendor/Module/registration.php & put below code.
add the module.xml file in Vendor/Module/etc/module.xml & put below code.
Create di.xml file in Vendor/Module/etc/di.xml & put below code.
Now, create LayoutProcessor.php in Vendor\Module\Plugin\LayoutProcessor & put below code
This will validate phone number on checkout