Magento 2 – Allow Special Characters in Checkout Phone Number Field

billing-addresscheckoutmagento2validation

In magento 2.1.X version checkout phone number should accept special character like (-) and should limit to 15 characters but currently it is accepting 10 characters only?
I did searched the core but could able to restrict and accept the special characters.

Best Answer

Magento 2 out of the box support special character like dash(-) and allow more than 10 character. Please check below link and image.

Magento 2 demo link: http://magento2-demo.nexcess.net

enter image description here

To validate number you can use validate-number in your module checkout_index_index.xml file.

<item name="telephone" xsi:type="array">
    <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 name="validation" xsi:type="array">
        <item name="min_text_length" xsi:type="number">10</item>
        <item name="max_text_length" xsi:type="number">10</item>
        <item name="validate-number" xsi:type="number">0</item>
    </item>
</item>
Related Topic