Vue检测密码复杂度方法
<!-- 检测密码复杂度方法 -->
<template>
<div>
<input type="password" v-model="password" @input="checkPasswordComplexity">
<div v-if="complexityMessage">{{ complexityMessage }}</div>
</div>
</template>
<script>
export default {
data() {
return {
password: '',
complexityMessage: ''
};
},
methods: {
checkPasswordComplexity() {
const complexityRegex = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}$/;
if (complexityRegex.test(this.password)) {
this.complexityMessage = '密码强度:强';
} else if (this.password.length >= 6) {
this.complexityMessage = '密码强度:中等';
} else {
this.complexityMessage = '密码强度:弱';
}
}
}
};
</script>
欢迎关注公-众-号【TaonyDaily】、留言、评论,一起学习。
Don’t reinvent the wheel, library code is there to help.
文章来源:刘俊涛的博客
若有帮助到您,欢迎点赞、转发、支持,您的支持是对我坚持最好的肯定(_)
标签:Vue,complexityMessage,复杂度,密码,complexityRegex,password From: https://www.cnblogs.com/lovebing/p/17932535.html