TransWikia.com

How to change the validation message in my account information section in myaccout page in Magento 2

Magento Asked on January 16, 2021

I wish to add custom validation message in my account information section
enter image description here

Please provide me a solution to add custom message in below template.

vendor/magento/module-customer/view/frontend/templates/form/edit.phtml

One Answer

You can add this data-msg-required="Please add confirm password." for custom validation password and for Validation you can try this.

create requirejs-config.js in your module with this code.

var config = {
    config: {
        mixins: {
            'mage/validation': {
                'Vendor_Module/js/validation-mixin': true
            }
        }
    }
}

Now add create validation-mixin.js file at Vendor_Module/view/frontend/web/js/validation-mixin.js with this code.

define([
    'jquery'
], function ($) {
    "use strict";

    return function () {
        $.validator.addMethod(
            'validate-minimum-age',
            function (value) {
                // Some custom validation stuff here
                return true or false;
            },
            $.mage.__('Your validation error message')
        );
    }
});

We can use same way for checkout.

Answered by kunj on January 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP