9

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?

2
  • 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 Commented May 30, 2016 at 2:44
  • It is a setting in the configuration, here's the official documentation: docs.magento.com/m2/ce/user_guide/customers/… Commented Nov 10, 2019 at 22:36

2 Answers 2

8

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"> 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> 
18

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.

8
  • Do you confirm that it works for you? For me it does not work! Magento 2.1.2 Commented Dec 17, 2016 at 16:20
  • I added images to my answer showing it works. Actually I'm on version 2.1.3 already Commented Dec 19, 2016 at 13:26
  • Thank you! It is probably a fix introduced in the new version 2.1.3. +1 for you for you availability. Commented Dec 19, 2016 at 20:32
  • These options are not visible to me on Magento 2.2.2 Commented Jan 22, 2018 at 5:02
  • @MJoraid I'm using M2.2.2 too, but I can find the options Commented Mar 15, 2018 at 5:20

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.