6 changed files with 71 additions and 23 deletions
@ -0,0 +1,48 @@ |
|||
export default { |
|||
data() { |
|||
return { |
|||
passwordSafeOne: 0, |
|||
passwordSafeTwo: 0 |
|||
} |
|||
}, |
|||
methods: { |
|||
// 进度格式
|
|||
progressFormatOne(percentage) { |
|||
if (percentage === 100) { |
|||
return '强' |
|||
} else if (percentage === 33) { |
|||
return '弱' |
|||
} else if (percentage === 66) { |
|||
return '中' |
|||
} |
|||
}, |
|||
// 设置密码强度
|
|||
passwordOneChange(password) { |
|||
// 正则表单案例2
|
|||
// 密码组成:纯数字、纯大小写字母
|
|||
// 密码强度:一种:弱; 两种组成:中; 三种混合:强
|
|||
// 密码长度校验
|
|||
// 清除清除上一次密码检验的结果
|
|||
// 密码强度校验
|
|||
const weakReg = /^[0-9]{8,}$|^[a-zA-Z]{8,}$/ |
|||
const mediumReg = /^(?:(?=.*[0-9])(?=.*[a-zA-Z])|(?=.*[0-9])(?=.*[^a-zA-Z0-9])|(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9])).{8,}$/ |
|||
const strongReg = /^(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,}$/ |
|||
if (password.length <= 0) { |
|||
this.passwordSafeOne = 0 |
|||
} else { |
|||
if (weakReg.test(password)) { |
|||
// 弱
|
|||
this.passwordSafeOne = 33 |
|||
} |
|||
if (mediumReg.test(password)) { |
|||
this.passwordSafeOne = 66 |
|||
} |
|||
if (strongReg.test(password)) { |
|||
// 强
|
|||
this.passwordSafeOne = 100 |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue