網站首頁 編程語言 正文
密碼強度如上圖片
涉及到的相關正則表達式:
export const PASSOWRD_REG_WEEK = /^[0-9]{6,8}$|^[A-Z]{6,8}$|^[a-z]{6,8}$|^[\W_!@#$%^&*`~()-+=]{6,8}$/;
// eslint-disable-next-line no-control-regex
export const PASSOWRD_REG_MIDDLE = /^(?!\d+$)(?![a-zA-Z]+$)[\da-zA-Z]{8,10}$|^(?!\d+$)(?![\x00-\xff]+$)[\d\x00-\xff]{8,10}$|^(?!a-zA-Z+$)(?![\x00-\xff]+$)[a-zA-Z\x00-\xff]{8,10}$/;
export const PASSOWRD_REG_POWER = /^(?=.*[a-zA-Z])(?=.*[\W_!@#$%^&*`~()-+=])(?=.*\d)[^]{10,16}$|^(?=.*[a-zA-Z])(?=.*[\W_!@#$%^&*`~()-+=])[^]{10,16}$|^(?=.*\d)(?=.*[\W_!@#$%^&*`~()-+=])[^]{10,16}$|^(?=.*[a-zA-Z])(?=.*\d)[^]{10,16}$/;
vue 頁面相關js部分
data() {
const validatePassword = (rule, value, callback) => {
if (this.activeName === 'first') {
if (value.length < 6 || value.length > 16) {
this.$refs.tip.style.display = 'none'
callback(new Error('密碼位數為6位 ~ 16位'));
} else if (value === '') {
callback(new Error('請輸入新密碼'));
} else if (validate.PASSOWRD_REG_WEEK.test(value)) {
this.$refs.level.innerText = '弱'
this.$refs.tip.style.display = 'block'
callback();
} else if (validate.PASSOWRD_REG_MIDDLE.test(value)) {
this.$refs.level.innerText = '中'
this.$refs.tip.style.display = 'block'
callback();
} else if (validate.PASSOWRD_REG_POWER.test(value)) {
this.$refs.level.innerText = '強'
this.$refs.tip.style.display = 'block'
callback();
}
} else {
if (value.length < 6 || value.length > 16) {
this.$refs.tip2.style.display = 'none'
callback(new Error('密碼位數為6位 ~ 16位'));
} else if (value === '') {
callback(new Error('請輸入新密碼'));
} else if (validate.PASSOWRD_REG_WEEK.test(value)) {
this.$refs.level2.innerText = '弱'
this.$refs.tip2.style.display = 'block'
callback();
} else if (validate.PASSOWRD_REG_MIDDLE.test(value)) {
this.$refs.level2.innerText = '中'
this.$refs.tip2.style.display = 'block'
callback();
} else if (validate.PASSOWRD_REG_POWER.test(value)) {
this.$refs.level2.innerText = '強'
this.$refs.tip2.style.display = 'block'
callback();
}
}
}
return {
loginRules: {
userPassword: [
{ required: true, message: '請輸入新密碼', trigger: 'blur' },
{ validator: validatePassword }
],
},
}
}
html部分
<el-form-item prop="userPassword">
<span class="svg-container">
<svg-icon icon-class="password" />
</span>
<el-input
:key="passwordType"
ref="userPassword"
v-model="resetForm.userPassword"
:type="passwordType"
placeholder="請輸入新密碼"
name="userPassword"
tabindex="2"
auto-complete="on"
@blur="clearLevel"
/>
<span class="el-form-item__error" ref="tip2" style="display:none;color:#666;">密碼安全等級:<span ref="level2"></span></span>
<!-- @keyup.enter.native="handleLogin"<span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span> -->
</el-form-item>
原文鏈接:https://blog.csdn.net/qq_38157825/article/details/108009556
- 上一篇:沒有了
- 下一篇:沒有了
相關推薦
- 2022-04-11 jackson中對null的處理
- 2022-12-07 進程狀態ps?-ef中的e、f含義講解_linux shell
- 2022-12-16 Docker教程之使用dockerfile生成鏡像_docker
- 2022-06-12 C語言超詳細講解棧的實現及代碼_C 語言
- 2023-10-09 使用Double Toke登錄的優點
- 2022-09-13 iOS自定義相機功能_IOS
- 2023-01-18 pip?search報錯問題及解決_python
- 2022-08-26 詳解WPF雙滑塊控件的使用和強制捕獲鼠標事件焦點_C#教程
- 欄目分類
-
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支