I want to add zip validation on my checkout page like right now if somebody put zip code like *6722 the order place I want some validation for special characters.

  • what is format support?
    – Amit Bera
    Commented Sep 11, 2019 at 7:58
  • how i check where i can check this?@Amit Bera
    – imtiazau
    Commented Sep 11, 2019 at 8:00

1 Answer 1


There two files you need to create.

  • First,Add additional CSS class to Postcode using plugin https://magento.stackexchange.com/a/205672/4564

    namespace MODULE\NAME\Model\Plugin;
    class AttributeMergerPlugin
        public function afterMerge(\Magento\Checkout\Block\Checkout\AttributeMerger $subject, $result)
            if (array_key_exists('postcode', $result)) {
                $result['postcode']['additionalClasses'] = 'your_css_custom_class';
            return $result;
  • Second, create a custom validation rule for javascript: Link: https://magento.stackexchange.com/a/192407/4564

file code: Vendor_Module/view/frontend/web/js/validation-mixin.js

], function ($) {
    "use strict";

    return function () {
            function (value) {
                // Some custom validation stuff here
                return true or false;
            $.mage.__('Your validation error message')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.