I would like to increase password security for customer and admin accounts in Magento. In addition to minimum password length, contain uppercase, lowercase, special characters, and digits.
I found the JavaScript file that controls the validation. Path:js/prototype/validation.js (Screenshot and code attached)
What is the appropriate code to be added?
['validate-password', 'Please enter 8 or more characters. Leading or trailing spaces will be ignored.', function(v) {
var pass=v.strip(); /*strip leading and trailing spaces*/
return !(pass.length>0 && pass.length < 8);
}],
['validate-admin-password', 'Please enter 7 or more characters. Password should contain both numeric and alphabetic characters.', function(v) {
var pass=v.strip();
if (0 == pass.length) {
return true;
}
if (!(/[a-z]/i.test(v)) || !(/[0-9]/.test(v))) {
return false;
}
return !(pass.length < 7);
}],
Thank you in advance for your help.
Best Answer
You can use below regular expression.
Explanation of this expression is
You can replace line
with
And change error message related to expression. You can do same for admin password.
For special character you can use below regular expression.
Minimum 8 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character from amongst these $@$!%*?&#^ .
You can use it like this way