We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

Please find the validation.js file in the vendor directory.

vendor/magento/module-customer/view/frontend/web/js/validation.js

Override validation.js file to your theme.

Replace the below code

define([
    'jquery',
    'moment',
    'jquery/validate',
    'mage/translate'
], function ($, moment) {
    'use strict';

    $.validator.addMethod(
        'validate-dob',
        function (value) {
            if (value === '') {
                return true;
            }

            return moment(value).isBefore(moment());
        },
        $.mage.__('The Date of Birth should not be greater than today.')
    );
});

with the below code

define([
    'jquery',
    'moment',
    'mageUtils',
    'jquery/validate',
    'validation',
    'mage/translate'
], function ($, moment, utils) {
    'use strict';

    $.validator.addMethod(
        'validate-dob',
        function (value, element, params) {
            var dateFormat = utils.convertToMomentFormat(params.dateFormat);

            if (value === '') {
                return true;
            }

            return moment(value, dateFormat).isBefore(moment());
        },
        $.mage.__('The Date of Birth should not be greater than today.')
    );
});

 

field_5bfb909c5ccae

    Recent Articles
    Get a Free Quote