Question

suppose , after a customer login into the website(you may need to sign up first as a customer), after a customer login then he click on change password option from the drop down , he will reach a window where he will type his new password --- But while typing the password he will see this error validation message "Minimum length of this field must be equal or greater than 8 symbols. Leading and trailing spaces will be ignored." , I want to edit this message , please guide me how can i do this. Thanks :)
Adding URL - wwww.mydomainname.com/customer/account/edit/changepass/1

Était-ce utile?

La solution

There is multiple way to edit validation text.

  1. It is a setting in the configuration, here's the official documentation: https://docs.magento.com/user-guide/customers/password-options.html

  2. You can edit from the file: vendor/magento/magento2-base/lib/web/mage/validation.js

  3. You can translate via i18n.

  4. Can create custom js validation:

    1. In input or select tag add our validation with this code:

      data-validate="{required:true, 'validate-custom-pass':true}"

    2. Add js validation for Validate-custom-pass

<script type="text/javascript">
    require([
    'jquery', // jquery Library
    'jquery/ui', // Jquery UI Library
    'jquery/validate', // Jquery Validation Library
    'mage/translate' // Magento text translate (Validation message translte as per language)
    ], function($){ 
    $.validator.addMethod(
    'validate-custom-pass', function (value) { 
    return (value.length >7); // Validation logic here modified length spelling
    }, $.mage.__('Password length should be minimum 8'));
    
    });
    </script>

Autres conseils

The solution which actually worked in my case is
I edited the code in this file
root_of_your_magento_folder/lib/web/mage/validation.js
Near line number 687

    'validate-customer-password': [      //line number 677
               function (v, elm) {
    .
    .(gap of 10 lines)
    .//line number 687 i commented the old and added the new line
    //validator.passwordErrorMessage = $.mage.__('Minimum length of this field must be equal or greater than %1 symbols. Leading and trailing spaces will be ignored.').replace('%1', passwordMinLength); //eslint-disable-line max-len <br>
    validator.passwordErrorMessage = $.mage.__('Minimum length of this field must be equal or greater than %1 symbols.').replace('%1', passwordMinLength); //eslint-disable-line max-len

Please feel free to ask me and know any more details

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top