I want to change the minimum length of password checking to 8. I tried changing validation.js rules.js but seems not work.

How can I change from 6 to 8?

  • I find it baffling that this wouldn't be a setting in the Magento 2 configuration. If it's not, it's definitely worth something contributing that change
    – scrowler
    May 30 '16 at 2:44
  • It is a setting in the configuration, here's the official documentation: docs.magento.com/m2/ce/user_guide/customers/…
    – Leland
    Nov 10 '19 at 22:36

We can use jQuery validation in Magento 2. You can add this file in '.phtml' or '.js' file.

Let’s see how we can do this.

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

validation script

<script type="text/javascript">
'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($){ 
'validate-custom-pass', function (value) { 
return (value.length >7); // Validation logic here modified length spelling
}, $.mage.__('Password length should be minimum 8'));


This is a configuration item. In Stores > Configuration > Customers > Customer Configuration > Password Options there's some options like Password Length and Number of Required Character Classes:

Password Options in admin Above I set the minimum password length to 20 and below I get the message when trying to create an account: Warning message about password length

Not sure at which version this was introduced but if you update your store to the latest version (I'm on 2.1.1) it will be available.

  • Do you confirm that it works for you? For me it does not work! Magento 2.1.2
    – Ervin
    Dec 17 '16 at 16:20
  • I added images to my answer showing it works. Actually I'm on version 2.1.3 already
    – Jacques
    Dec 19 '16 at 13:26
  • Thank you! It is probably a fix introduced in the new version 2.1.3. +1 for you for you availability.
    – Ervin
    Dec 19 '16 at 20:32
  • It works for me in Magento 2.1.1. thanks
    – BornCoder
    Jan 16 '17 at 6:27
  • These options are not visible to me on Magento 2.2.2 Jan 22 '18 at 5:02

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.