Hello,
I have validated zip code field in customer address as a Numeric Only.
configure : Store->Attributes -> Customer Address ->Postcode ->Input Validation -Numeric Only.
But This field is taking single space (not showing validation message) with numbers.
For 2 continuous spaces the validation message is showing.
Solved! Go to Solution.
Hello @varshanema519b
To add validation on the zip field we should overwrite Magento_Checkout/layout/checkout_index_index.xml and add this code :
<item name="postcode" xsi:type="array"> <item name="sortOrder" xsi:type="string">75</item> <!-- post-code field has custom UI component --> <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>
zip-range for example is a already defined rule in rules.js
We can overwrite this rule or we can create another rule according to our needs in this location:Theme\Theme\Magento_Ui\web\js\lib\validation\rules.js
It may help you!
Thank you
Hello @varshanema519b
To add validation on the zip field we should overwrite Magento_Checkout/layout/checkout_index_index.xml and add this code :
<item name="postcode" xsi:type="array"> <item name="sortOrder" xsi:type="string">75</item> <!-- post-code field has custom UI component --> <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>
zip-range for example is a already defined rule in rules.js
We can overwrite this rule or we can create another rule according to our needs in this location:Theme\Theme\Magento_Ui\web\js\lib\validation\rules.js
It may help you!
Thank you
Thank you.
It is working.