cancel
Showing results for 
Search instead for 
Did you mean: 

Postcode Validation on Edit customer address page's attributes in address book.

SOLVED

Postcode Validation on Edit customer address page's attributes in address book.

Hello,
I can validate the PostCode on checkout page by changing the file app/design/frontend/Theme/Magento_Checkout/layout/checkout_index_index.xml with the code :

<item name="postcode" xsi:type="array">
<item name="sortOrder" xsi:type="string">75</item>
<item name="component" xsi:type="string">Magento_Ui/js/form/element/post-code</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="string">true</item>
<item name="validate-zip-us" xsi:type="string">true</item>
</item>
</item>

But this code not reflected on Edit Customer address page in address book(in my account).

Can anyone suggest me solution on this issue.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Postcode Validation on Edit customer address page's attributes in address book.

Hi @varshanema519b ,

 

You need to overright vendor/magento/module-customer/view/frontend/templates/address/edit.phtml to modify or add new validation for zipcode.

 

In this file you can find below code:

<input type="text"
name="postcode"
value="<?= $escaper->escapeHtmlAttr($block->getAddress()->getPostcode()) ?>"
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>"
id="zip"
class="input-text validate-zip-international
<?= $escaper->escapeHtmlAttr($_postcodeValidationClass) ?>">

 

You can modify class validation in your over righted file.

 

Problem Solved? Accept as Solution!

 

Hope it helps!

Thanks

Ankit Jasani

View solution in original post

2 REPLIES 2

Re: Postcode Validation on Edit customer address page's attributes in address book.

Hi @varshanema519b ,

 

You need to overright vendor/magento/module-customer/view/frontend/templates/address/edit.phtml to modify or add new validation for zipcode.

 

In this file you can find below code:

<input type="text"
name="postcode"
value="<?= $escaper->escapeHtmlAttr($block->getAddress()->getPostcode()) ?>"
title="<?= /* @noEscape */ $block->getAttributeData()->getFrontendLabel('postcode') ?>"
id="zip"
class="input-text validate-zip-international
<?= $escaper->escapeHtmlAttr($_postcodeValidationClass) ?>">

 

You can modify class validation in your over righted file.

 

Problem Solved? Accept as Solution!

 

Hope it helps!

Thanks

Ankit Jasani

Re: Postcode Validation on Edit customer address page's attributes in address book.

Hello ,
How can I validate Postcode at change shipping address in my subscription page in My account ?