0

I want to add validation for firstname and lastname except only characters with mininum 50 in Checkout page for shipping and billing in Magento2.1.7?

Refer my Screenshot.

enter image description here

1

You need to override the checkout_index_index.xml in your custom theme.

and add the below code for custom validation for firstname and lastname

<item name="firstname" xsi:type="array">
    <item name="validation" xsi:type="array">
        <item name="letters-only" xsi:type="string">true</item>
        <item name="max_text_length" xsi:type="number">50</item>
    </item>
</item>
<item name="lastname" xsi:type="array">
    <item name="validation" xsi:type="array">
        <item name="letters-only" xsi:type="string">true</item>
        <item name="max_text_length" xsi:type="number">50</item>
    </item>
</item>
  • I want to add validation only accept letter not numeric in first name and last name, please help me how to achieve this? – Purushotam Sharma Apr 8 at 9:50
  • On registration page – Purushotam Sharma Apr 8 at 10:07
0

You need to override the checkout_index_index.xml within your module or your custom theme.

and add the below node for the custom vlidation

<item name="firstname" xsi:type="array">
    <item name="validation" xsi:type="array">
        <item name="your-custom-validation" xsi:type="string">true</item>
        <item name="letters-only" xsi:type="string">true</item>
    </item>
</item>

After that You need to create your-custom-validation rule.

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.