I have this message when i validate post code

enter image description here

How to change it? I tried overriding postcode-validator.js

'Magento_Ui/js/model/messageList'], function ($, utils, messageContainer) {
'use strict';

return {
    validatedPostCodeExample: [],

     * @param {*} postCode
     * @param {*} countryId
     * @return {Boolean}
    validate: function (postCode, countryId) {
        var patterns = window.checkoutConfig.postCodes[countryId],
            pattern, regex;

        this.validatedPostCodeExample = [];

        console.log("RADI" + postCode + countryId);

        $.get("/checker/PostalCode/CheckPostalCode", {data:postCode}, function (data) {
            console.log("Response text " + data.data);

        return true;


But this display only this default message. I tried adding this in postcode input field but no luck:

$('input[name=postcode]').attr('data-msg-required','Please can you work!.');
  • What do you want actually? you want to override postcode-validator.js – Prathap Gunasekaran Feb 13 at 13:20
  • @GPrathap Yes i want to override postcode-validator.js in a way that it can check postcode not by regex but with some api and display custom message in div I screenshoted in post. I just want to display any text in that div and span. – Varikap Feb 13 at 13:24

Try this, First copy postcode-validator.js from




then Create require-config.js inside you module frontend folder and then add below code

var config = {
map: {
    '*': {
        'Magento_Checkout/js/modal/postcode-validator': 'Vendor_Module/js/modal/postcode-validator'

Then it will override the core postcode-validator.js

  • Thanks, that worked. But how i can change text in div when error occurs? Like this one from picture at start of my question. I want to put custom text in that div. Thanks in advance! – Varikap Feb 18 at 8:45
  • So basically you validation right? – Prathap Gunasekaran Feb 18 at 8:47
  • Well, yes. I just want to check zip code and display my message when it is not good. – Varikap Feb 18 at 8:50
  • Which form is this? I mean shipping or your custom page form? – Prathap Gunasekaran Feb 18 at 8:51
  • Yes, it is default form on checkout/#shipping – Varikap Feb 18 at 9:09

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.