|
@@ -13,7 +13,28 @@
|
13
|
13
|
width: auto;
|
14
|
14
|
padding-right: 10px;
|
15
|
15
|
line-height: 38px;
|
|
16
|
+ font-weight: bold;
|
16
|
17
|
}
|
|
18
|
+ .layuimini-container {
|
|
19
|
+ display: flex;
|
|
20
|
+ justify-content: center;
|
|
21
|
+ align-items: center;
|
|
22
|
+ height: 100vh;
|
|
23
|
+ font-size: 16px;
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ .layuimini-main {
|
|
27
|
+ width: 600px; /* Adjust width as needed */
|
|
28
|
+ }
|
|
29
|
+ .layuimini-container .layuimini-main .layui-input-block tip {
|
|
30
|
+ font-size: 12px;
|
|
31
|
+ position: relative;
|
|
32
|
+ display: inline-block;
|
|
33
|
+ margin-left: 5px; /* 调整注释与输入框之间的距离 */
|
|
34
|
+ color: red; /* 设置注释的颜色 */
|
|
35
|
+ line-height: 14px;
|
|
36
|
+ }
|
|
37
|
+
|
17
|
38
|
</style>
|
18
|
39
|
</head>
|
19
|
40
|
<body>
|
|
@@ -22,26 +43,27 @@
|
22
|
43
|
|
23
|
44
|
<div class="layui-form layuimini-form">
|
24
|
45
|
<div class="layui-form-item">
|
25
|
|
- <label class="layui-form-label required">旧的密码</label>
|
|
46
|
+ <label class="layui-form-label required">旧密码</label>
|
26
|
47
|
<div class="layui-input-block">
|
27
|
|
- <input type="password" name="old_password" lay-verify="required" lay-reqtext="旧的密码不能为空"
|
28
|
|
- placeholder="请输入旧的密码" value="" class="layui-input">
|
29
|
|
- <tip>填写自己账号的旧的密码。</tip>
|
|
48
|
+ <input type="password" name="old_password" lay-verify="required" lay-reqtext="旧密码不能为空"
|
|
49
|
+ placeholder="请输入旧密码" value="" class="layui-input">
|
30
|
50
|
</div>
|
31
|
51
|
</div>
|
32
|
52
|
|
33
|
53
|
<div class="layui-form-item">
|
34
|
|
- <label class="layui-form-label required">新的密码</label>
|
|
54
|
+ <label class="layui-form-label required">新密码</label>
|
35
|
55
|
<div class="layui-input-block">
|
36
|
|
- <input type="password" name="new_password" lay-verify="required|pass" lay-reqtext="新的密码不能为空"
|
37
|
|
- placeholder="请输入新的密码" value="" class="layui-input">
|
38
|
|
- <tip>密码需包含大写字母,小写字母,特殊符号(@、$、!、%、*、?、&),且密码长度不能少于8位,密码范例(Zhangsan@123456)</tip>
|
|
56
|
+ <input type="password" name="new_password" id="new_password" lay-verify="required|pass" lay-reqtext="新密码不能为空"
|
|
57
|
+ placeholder="请输入新密码" value="" class="layui-input">
|
|
58
|
+ <tip>
|
|
59
|
+ 注:新密码需包含大写字母、小写字母、特殊符号(@、$、!、%、*、?、&),且密码长度不能少于8位,例如:Zhangsan@123456
|
|
60
|
+ </tip>
|
39
|
61
|
</div>
|
40
|
62
|
</div>
|
41
|
63
|
<div class="layui-form-item">
|
42
|
|
- <label class="layui-form-label required">再输入一遍</label>
|
|
64
|
+ <label class="layui-form-label required">确认密码</label>
|
43
|
65
|
<div class="layui-input-block">
|
44
|
|
- <input type="password" name="again_password" lay-verify="required|pass" lay-reqtext="新的密码不能为空"
|
|
66
|
+ <input type="password" name="again_password" id="again_password" lay-verify="required|pass" lay-reqtext="新密码不能为空"
|
45
|
67
|
placeholder="请输入新的密码" value="" class="layui-input">
|
46
|
68
|
</div>
|
47
|
69
|
</div>
|
|
@@ -82,7 +104,9 @@
|
82
|
104
|
const regex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&]).{8,}$/;
|
83
|
105
|
|
84
|
106
|
if (!regex.test(new_password)) {
|
85
|
|
- layer.msg('密码强度较弱!保存失败')
|
|
107
|
+ layer.msg('密码强度较弱!保存失败');
|
|
108
|
+ document.getElementById('new_password').value = '';
|
|
109
|
+ document.getElementById('again_password').value = '';
|
86
|
110
|
return false;
|
87
|
111
|
}
|
88
|
112
|
|
|
@@ -114,6 +138,30 @@
|
114
|
138
|
return false;
|
115
|
139
|
});
|
116
|
140
|
|
|
141
|
+// 监听新密码输入框的变化
|
|
142
|
+ $('input[name="new_password"]').on('input', function () {
|
|
143
|
+ var password = $(this).val();
|
|
144
|
+ var pattern = new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&]).{8,}$/);
|
|
145
|
+ var tipText, color;
|
|
146
|
+ if (pattern.test(password)) {
|
|
147
|
+ tipText = '密码强度:强';
|
|
148
|
+ color = '#00BB00'; // 蓝色
|
|
149
|
+ } else if (password.length >= 6 && password.length < 8) {
|
|
150
|
+ tipText = '密码强度:中';
|
|
151
|
+ color = '#4A4AFF'; // 黄色
|
|
152
|
+ } else {
|
|
153
|
+ tipText = '密码强度:弱';
|
|
154
|
+ color = 'red'; // 红色
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ // 移除旧的提示信息
|
|
158
|
+ $(this).next('.password-tip').remove();
|
|
159
|
+
|
|
160
|
+ // 添加新的提示信息
|
|
161
|
+ $(this).after('<div class="password-tip" style="color: ' + color + ';">' + tipText + '</div>');
|
|
162
|
+ });
|
|
163
|
+
|
|
164
|
+
|
117
|
165
|
// form.verify({
|
118
|
166
|
// pass: function(value, item){ //value:表单的值、item:表单的DOM对象
|
119
|
167
|
// // 密码中必须包含字母(不区分大小写)、数字、特称字符,至少8个字符,最多30个字符;
|