Magento 2 How to change password length validation?

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.


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>