Skip to content

Commit a960b1c

Browse files
Update JS validation of password field
1 parent 7b3e4dc commit a960b1c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

view/adminhtml/requirejs-config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var config = {
2+
config: {
3+
mixins: {
4+
'mage/validation': {
5+
'Aligent_Pci4Compatibility/js/system/config/validator-mixin': true
6+
},
7+
}
8+
}
9+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
define([
2+
'jquery'
3+
], function ($) {
4+
'use strict';
5+
6+
return function (target) {
7+
$.validator.addMethod(
8+
'validate-admin-password',
9+
function (v) {
10+
var pass;
11+
12+
if (v == null) {
13+
return false;
14+
}
15+
// strip leading and trailing spaces
16+
pass = v.trim();
17+
// password is not being changed
18+
if (pass.length === 0) {
19+
return true;
20+
}
21+
22+
if (!/[a-z]/i.test(v) || !/[0-9]/.test(v)) {
23+
return false;
24+
}
25+
26+
return pass.length >= 12;
27+
},
28+
$.mage.__('Please enter 12 or more characters, using both numeric and alphabetic.')
29+
);
30+
31+
return target;
32+
};
33+
});

0 commit comments

Comments
 (0)