Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to change the required minimum password length? 
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

Does anyone know how to change the customer password requirements from 6 characters to something else?
Running 1.1.6.

 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

downer

 
Magento Community Magento Community
Magento Community
Magento Community
 
J_T_
Mentor
 
Avatar
Total Posts:  1961
Joined:  2008-08-07
London-ish, UK
 

Simple to find if you know a bit of PHP.

If the requirement is 6 you can assume there will be code using strlen to check this.

So all I did was grep -i -r strlen magento/app

There it is:

app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Password.php

if(Mage::helper('core/string')->strlen($password)<6){
 
Magento Community Magento Community
Magento Community
Magento Community
 
turbo1
Sr. Member
 
Avatar
Total Posts:  296
Joined:  2008-08-19
Los Angeles, CA
 

THANK YOU
my sincere gratitude. I don’t know much PHP so I would have never found it.

 
Magento Community Magento Community
Magento Community
Magento Community
 
mcaaitguy
Jr. Member
 
Total Posts:  2
Joined:  2008-10-21
 

I edited the app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Password.php file and removed the requirement completely but the cart still requires a six character password.  I want to knock it down to only five.  Is there another file aside from this one that I need to edit?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emily
Jr. Member
 
Avatar
Total Posts:  22
Joined:  2008-03-31
Atlanta
 

The customer login form on the my account section also uses javascript to validate form input.  In js/prototyp/validation.js, on line 370 (search for the string ‘validate-password’).  Change both of the 6’s to whatever limit you want.

['validate-password''Please enter 6 or more characters. Leading or trailing spaces will be ignored.', function(v{
                
var pass=v.strip(); /*strip leading and trailing spaces*/
                
return !(pass.length>&& pass.length 6);
 
Magento Community Magento Community
Magento Community
Magento Community
 
mcaaitguy
Jr. Member
 
Total Posts:  2
Joined:  2008-10-21
 

Emily, you are my hero.  Thank you so much!

 
Magento Community Magento Community
Magento Community
Magento Community
 
davidd
Jr. Member
 
Total Posts:  10
Joined:  2009-04-15
 

AWESOME!!

Thanks for pointing out the code to change.  I needed to drop the password requirement to 5 characters also on my site.

Out of curiosity, there is another snippet of code in validation.js that mentions 6 characters. 

['validate-new-password''Please enter 6 or more characters. Leading or trailing spaces will be ignored.', function(v{
                
if (!Validation.get('validate-password').test(v)) return false;
                if (
Validation.get('IsEmpty').test(v) && != '') return false;
                return 
true;
            
}],
I couldn’t tell what it affected, so I just changed to it to say “5 or more characters”.

I assume that the modification in both files will be overwritten during an upgrade via MagentoConnect.

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

The modifications done on validation.js will be gone when Magento is updated with new versions. Is there a way to do a js update like the template or skin update?

 
Magento Community Magento Community
Magento Community
Magento Community
 
kiatng
Enthusiast
 
Total Posts:  875
Joined:  2008-09-03
Kuala Lumpur, Malaysia
 

Check out the author of validation.js here http://tetlaw.id.au/view/javascript/really-easy-field-validation.  It is possible to add custom validation to the js thereby creating a kind of js update without worry about the rewrite by Magento update.  For example: in the phtml file, specify the custom class in the input field, in my case validate-awb:

<input name="awb" type="text" id="awb" class="validate-awb input-text">

I want the input text to be within 9 to 12 digits, the js code inserted within the same phtml file is

<script type="text/javascript">
    
//<![CDATA[
        
var trackForm = new VarienForm('track-awb');
        
Validation.add('validate-awb''Please use 9 to 12 numbers only in this field.'{
          minLength 
9,
          
maxLength 12,
          include : 
['validate-digits']            
        }
);
    
//]]>
</script>

Note, I included the in-built function validate-digits to validate for numbers. 

So far so good. But I need to be able to return a backend validation message/advise, and I do not know enough js and AJAX to do it. Can anyone throw some light? Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
rreece0113
Sr. Member
 
Total Posts:  76
Joined:  2009-01-28
Oregon
 

I have made both edits to files and see no change on the customer registration page. Still wont let me register with less than 6 characters.

Very frustrating.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jack.webster
Jr. Member
 
Total Posts:  1
Joined:  2010-06-21
 

Hi Devin, guys,

I have just been struggling along with the similar problem and got it working after following advice in this thread.

A lot of the validation code seems fairly spread out between files. For anyone interested, the JavaScript change is necessary to prevent validation failing before postback, the other validation is done later, server-side.

Anyway, after following the instructions above, I still couldn’t save a shorter password until I edited the following class:

Mage_Customer_Model_Customer_Attribute_Backend_Password

There is a method in there called beforeSave() that also checks the length of the password. Setting this to my new desired length did the trick for me. Hope this helps!

 
Magento Community Magento Community
Magento Community
Magento Community
 
akonopka
Jr. Member
 
Total Posts:  3
Joined:  2010-10-21
 

Copy this file:

app/code/core/Mage/Customer/Model/Customer/Model/Customer.php

to the folder

app/code/local/Mage/Customer/Model/Customer/Model/

and then modify these lines:

if ($password && !Zend_Validate::is($password\'StringLength\', array(6))) {
$errors[] 
Mage::helper(\'customer\')->__(\'Password minimal length must be more %s\'6);
}

The modifications in files:

\\app\\code\\core\\Mage\\Customer\\Model\\Customer\\Attribute\\Backend\\Password.php
\\app\\code\\core\\Mage\\Core\\Helper\\Js.php

(copy them to the folders:
\\app\\code\\local\\Mage\\Customer\\Model\\Customer\\Attribute\\Backend\\
\\app\\code\\local\\Mage\\Core\\Helper\\
)

and in the files:

\\js\\prototype\\validation.js

\\app\\locale\\en_US\\Mage_Core.csv
\\app\\locale\\de_DE\\Mage_Core.csv

may also be necessary.

 
Magento Community Magento Community
Magento Community
Magento Community
 
akonopka
Jr. Member
 
Total Posts:  3
Joined:  2010-10-21
 

Copy this file:

app/code/core/Mage/Customer/Model/Customer/Model/Customer.php

to the folder

app/code/local/Mage/Customer/Model/Customer/Model/

and then modify these lines:

if ($password && !Zend_Validate::is($password'StringLength', array(6))) {
$errors[] 
Mage::helper('customer')->__('Password minimal length must be more %s'6);
}

The modifications in files:

\app\code\core\Mage\Customer\Model\Customer\Attribute\Backend\Password.php
\app\code\core\Mage\Core\Helper\Js.php

(copy them to the folders:
\app\code\local\Mage\Customer\Model\Customer\Attribute\Backend\
\app\code\local\Mage\Core\Helper\
)

and in the files:

\js\prototype\validation.js

\app\locale\en_US\Mage_Core.csv
\app\locale\de_DE\Mage_Core.csv

may also be necessary.

 
Magento Community Magento Community
Magento Community
Magento Community
 
akonopka
Jr. Member
 
Total Posts:  3
Joined:  2010-10-21
 

Copy this file:

app/code/core/Mage/Customer/Model/Customer/Model/Customer.php

to the folder

app/code/local/Mage/Customer/Model/Customer/Model/

and then modify these lines:

if ($password && !Zend_Validate::is($password\'StringLength\', array(6))) {
$errors[] 
Mage::helper(\'customer\')->__(\'Password minimal length must be more %s\'6);
}

The modifications in files:

/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Password.php
/app/code/core/Mage/Core/Helper/Js.php

(copy them to the folders:
/app/code/local/Mage/Customer/Model/Customer/Attribute/Backend/
/app/code/local/Mage/Core/Helper/
)

and in the files:

/js/prototype/validation.js

/app/locale/en_US/Mage_Core.csv
/app/locale/de_DE/Mage_Core.csv

may also be necessary.

 
Magento Community Magento Community
Magento Community
Magento Community
 
clickshopdario
Jr. Member
 
Total Posts:  1
Joined:  2012-07-30
 
akonopka - 15 June 2011 10:56 PM

Copy this file:

app/code/core/Mage/Customer/Model/Customer/Model/Customer.php

to the folder

app/code/local/Mage/Customer/Model/Customer/Model/

and then modify these lines:

if ($password && !Zend_Validate::is($password\'StringLength\', array(6))) {
$errors[] 
Mage::helper(\'customer\')->__(\'Password minimal length must be more %s\'6);
}

The modifications in files:

/app/code/core/Mage/Customer/Model/Customer/Attribute/Backend/Password.php
/app/code/core/Mage/Core/Helper/Js.php

(copy them to the folders:
/app/code/local/Mage/Customer/Model/Customer/Attribute/Backend/
/app/code/local/Mage/Core/Helper/
)

and in the files:

/js/prototype/validation.js

/app/locale/en_US/Mage_Core.csv
/app/locale/de_DE/Mage_Core.csv

may also be necessary.

You have also to modify here:

app\code\core\Mage\ImportExport\Model\Import\Entity\Customer.php

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top