JavaScript   发布时间:2022-04-16  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了js密码强度检测大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲解了js密码强度检测的实现代码,分享给大家供大家参,具体内容如下

运行效果图:

js密码强度检测

便用户改进输入。

代码:

JS判断密码强度
密码: @H_874_57@密码强度:

js密码强度检测

具体内容:

function AuthPasswd(String) { if(String.length >=6) { if(/[a-zA-Z]+/.test(String) && /[0-9]+/.test(String) && /\W+\D+/.test(String)) { noticeAssign(1); }else if(/[a-zA-Z]+/.test(String) || /[0-9]+/.test(String) || /\W+\D+/.test(String)) { if(/[a-zA-Z]+/.test(String) && /[0-9]+/.test(String)) { noticeAssign(-1); }else if(/\[a-zA-Z]+/.test(String) && /\W+\D+/.test(String)) { noticeAssign(-1); }else if(/[0-9]+/.test(String) && /\W+\D+/.test(String)) { noticeAssign(-1); }else{ noticeAssign(0); } } }else{ noticeAssign(null); } }

function noticeAssign(num) {
if(num == 1) {
$('#weak').css({BACkgroundColor:'#009900'});
$('#middle').css({BACkgroundColor:'#009900'});
$('#strength').css({BACkgroundColor:'#009900'});
$('#strength').html('很强');
$('#middle').html('');
$('#weak').html('');
}else if(num == -1){
$('#weak').css({BACkgroundColor:'#ffcc33'});
$('#middle').css({BACkgroundColor:'#ffcc33'});
$('#strength').css({BACkgroundColor:''});
$('#weak').html('');
$('#middle').html('中');
$('#strength').html('');
}else if(num ==0) {
$('#weak').css({BACkgroundColor:'#dd0000'});
$('#middle').css({BACkgroundColor:''});
$('#strength').css({BACkgroundColor:''});
$('#weak').html('弱');
$('#middle').html('');
$('#strength').html('');
}else{
$('#weak').html('');
$('#middle').html('');
$('#strength').html('');
$('#weak').css({BACkgroundColor:''});
$('#middle').css({BACkgroundColor:''});
$('#strength').css({BACkgroundColor:''});
}
}

以上就是本文的全部内容,希望对大家学习javascript程序设计有所帮助。

大佬总结

以上是大佬教程为你收集整理的js密码强度检测全部内容,希望文章能够帮你解决js密码强度检测所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。