|
@@ -156,7 +156,7 @@ |
|
@@ -156,7 +156,7 @@ |
156
|
</tr>
|
156
|
</tr>
|
157
|
<tr>
|
157
|
<tr>
|
158
|
<td class="kv-label"><spring:message code="user.newpwd"/></td>
|
158
|
<td class="kv-label"><spring:message code="user.newpwd"/></td>
|
159
|
- <td class="kv-content"><input type="password" name="newpassword" id="newpassword" required maxlength="30"><span id="showStrength"></span>
|
159
|
+ <td class="kv-content"><input type="password" name="newpassword" id="newpassword" onblur="regularValue()" required maxlength="30"><span id="showStrength"></span>
|
160
|
</td>
|
160
|
</td>
|
161
|
</tr>
|
161
|
</tr>
|
162
|
<tr>
|
162
|
<tr>
|
|
@@ -250,6 +250,16 @@ |
|
@@ -250,6 +250,16 @@ |
250
|
var newpassword = $("#newpassword").val();
|
250
|
var newpassword = $("#newpassword").val();
|
251
|
var confirmnewpassword = $("#confirmnewpassword").val();
|
251
|
var confirmnewpassword = $("#confirmnewpassword").val();
|
252
|
var id = $("#id").val();
|
252
|
var id = $("#id").val();
|
|
|
253
|
+
|
|
|
254
|
+
|
|
|
255
|
+ var passwords = $("#newpassword").val();
|
|
|
256
|
+
|
|
|
257
|
+ var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
|
|
|
258
|
+
|
|
|
259
|
+ var re = new RegExp(reg);
|
|
|
260
|
+
|
|
|
261
|
+ if (re.test(passwords)){
|
|
|
262
|
+
|
253
|
$.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){
|
263
|
$.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){
|
254
|
if(data.status==500){
|
264
|
if(data.status==500){
|
255
|
layer.open({content:"<spring:message code="user.differpwd"/>"});
|
265
|
layer.open({content:"<spring:message code="user.differpwd"/>"});
|
|
@@ -266,7 +276,38 @@ |
|
@@ -266,7 +276,38 @@ |
266
|
})
|
276
|
})
|
267
|
}
|
277
|
}
|
268
|
})
|
278
|
})
|
|
|
279
|
+
|
|
|
280
|
+ }else {
|
|
|
281
|
+ //不符合规则
|
|
|
282
|
+ showStrength.innerHTML = "密码不少于8位,英文大小写、数字、特殊符号等相结合".fontcolor("red");
|
|
|
283
|
+ document.getElementById("newpassword").className = "icon into";
|
|
|
284
|
+ return false;
|
|
|
285
|
+ }
|
269
|
}
|
286
|
}
|
|
|
287
|
+
|
|
|
288
|
+
|
|
|
289
|
+ function regularValue() {
|
|
|
290
|
+
|
|
|
291
|
+ var passwords = $("#newpassword").val();
|
|
|
292
|
+
|
|
|
293
|
+ var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
|
|
|
294
|
+
|
|
|
295
|
+ var re = new RegExp(reg);
|
|
|
296
|
+
|
|
|
297
|
+ if (re.test(passwords)){
|
|
|
298
|
+ //符合规则
|
|
|
299
|
+ showStrength.innerHTML = "".fontcolor("green");
|
|
|
300
|
+ document.getElementById("newpassword").className = "icon ticker";
|
|
|
301
|
+ return true;
|
|
|
302
|
+ }else {
|
|
|
303
|
+ //不符合规则
|
|
|
304
|
+ showStrength.innerHTML = "密码不少于8位,英文大小写、数字、特殊符号等相结合".fontcolor("red");
|
|
|
305
|
+ document.getElementById("newpassword").className = "icon into";
|
|
|
306
|
+ return false;
|
|
|
307
|
+ }
|
|
|
308
|
+
|
|
|
309
|
+ }
|
|
|
310
|
+
|
270
|
</script>
|
311
|
</script>
|
271
|
<script type="text/javascript">
|
312
|
<script type="text/javascript">
|
272
|
|
313
|
|
|
@@ -313,88 +354,7 @@ |
|
@@ -313,88 +354,7 @@ |
313
|
}
|
354
|
}
|
314
|
|
355
|
|
315
|
|
356
|
|
316
|
- // 验证密码强度
|
|
|
317
|
- $("#newpassword")window.onload = function () {
|
|
|
318
|
- function setCss(_this,cssOption){
|
|
|
319
|
- //判断节点类型
|
|
|
320
|
- if (!_this || _this.nodeType ===3 || _this.nodeType === 8 ||!_this.style) {
|
|
|
321
|
- return;
|
|
|
322
|
- }
|
|
|
323
|
- for(var cs in cssOption){
|
|
|
324
|
- _this.style[cs] = cssOption[cs];
|
|
|
325
|
- }
|
|
|
326
|
- return _this;
|
|
|
327
|
- }
|
|
|
328
|
-
|
|
|
329
|
- function trim(chars){
|
|
|
330
|
- return (chars ||"").replace(/^(\s|\u00a0)+|(\s|\u00a0)+$/g,"");
|
|
|
331
|
- }
|
|
|
332
|
- function passwordStrength(newpassword,showStrength){
|
|
|
333
|
- var self = this;
|
|
|
334
|
-
|
|
|
335
|
- /*字符权重;
|
|
|
336
|
- 数字1,字母2,其他字符为3
|
|
|
337
|
- 当密码长度小于6时不符合标准
|
|
|
338
|
- 长度>=6,强度小于10,强度弱
|
|
|
339
|
- 长度>=6,长度>=10且<15,强度中
|
|
|
340
|
- 长度>=6,强度>=15,强*/
|
|
|
341
|
- passwordStrength.onkeyup = function(){
|
|
|
342
|
- var _color = ["red","yellow","orange","green"],
|
|
|
343
|
- msgs = ["密码太短","弱","中","强"],
|
|
|
344
|
- _strength = 0,
|
|
|
345
|
- _v= trim(newpassword.value),
|
|
|
346
|
- _vL= _v.length,
|
|
|
347
|
- i=0;
|
|
|
348
|
-
|
|
|
349
|
- var charStrength = function(char){
|
|
|
350
|
- //计算单个字符强度
|
|
|
351
|
- if(char>=48 && char <=57){//数字
|
|
|
352
|
- return 1;
|
|
|
353
|
- }
|
|
|
354
|
- if(char>=97 && char<=122){//小写
|
|
|
355
|
- return 2;
|
|
|
356
|
- }else{
|
|
|
357
|
- return 3; //特殊字符
|
|
|
358
|
- }
|
|
|
359
|
- }
|
|
|
360
|
-
|
|
|
361
|
- if(_vL<8){//计算模式
|
|
|
362
|
- showStrength.innerText = msgs[0];
|
|
|
363
|
- setCss(showStrength,{
|
|
|
364
|
- "color":_color[0]
|
|
|
365
|
- })
|
|
|
366
|
- }else{
|
|
|
367
|
- for(;i<_vL;i++){
|
|
|
368
|
- //遍历字符
|
|
|
369
|
- _strength+=charStrength(_v.toLocaleLowerCase().charCodeAt(i));
|
|
|
370
|
- }
|
|
|
371
|
- if(_strength<10){
|
|
|
372
|
- //强度小于10
|
|
|
373
|
- showStrength.innerText = msgs[1];
|
|
|
374
|
- setCss(showStrength,{
|
|
|
375
|
- "color":_color[1]
|
|
|
376
|
- })
|
|
|
377
|
- }
|
|
|
378
|
- if(_strength>=10&&_strength<15){
|
|
|
379
|
- showStrength.innerText = msgs[2];
|
|
|
380
|
- setCss(showStrength,{
|
|
|
381
|
- "color":_color[2]
|
|
|
382
|
- })
|
|
|
383
|
- }
|
|
|
384
|
- if(_strength>=15){
|
|
|
385
|
- showStrength.innerText = msgs[3];
|
|
|
386
|
- setCss(showStrength,{
|
|
|
387
|
- "color":_color[3]
|
|
|
388
|
- })
|
|
|
389
|
- }
|
|
|
390
|
- }
|
|
|
391
|
- }
|
|
|
392
|
- }
|
|
|
393
|
- passwordStrength(
|
|
|
394
|
- document.getElementById("newpassword"),
|
|
|
395
|
- document.getElementById("showStrength"));
|
|
|
396
|
|
357
|
|
397
|
- };
|
|
|
398
|
|
358
|
|
399
|
</script>
|
359
|
</script>
|
400
|
</body>
|
360
|
</body>
|