当前位置:网站首页>Day 239/300 注册密码长度为8~14个字母数字以及标点符号至少包含2种校验
Day 239/300 注册密码长度为8~14个字母数字以及标点符号至少包含2种校验
2022-07-06 06:28:00 【Arden Zhao】
(一)需求
注册密码要做校验,要求是:
- 长度为8~14个字符
- 字母数字以及标点符号至少包含2种
- 不允许有空格、中文
(二)思路
1、每个条件单独校验
- 长度为8~14个字符
str.length
- 字母数字以及标点符号至少包含2种
- 不允许有空格、中文
2、正则校验
const rules = /(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^[^\s\u4e00-\u9fa5]{8,14}$/
if (!rules.test(value)) {
return Promise.reject('长度为8~14;字母数字以及标点符号至少包含2种;不允许有空格、中文')
}
(三)其他用到的正则
1、手机号
const phone = /^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/
if (!phone.test(this.form.account)) {
message.warning('手机号格式不正确')
return
}
2、邮箱
const email = /^\w+(\.)?(\w+)[email protected][0-9a-z]+(\.[a-z]+){1,3}$/
if (!email.test(this.form.account)) {
message.warning('邮箱格式不正确')
return false
}
写在最后的话
学习路上,常常会懈怠
《有想学技术需要监督的同学嘛~》
https://mp.weixin.qq.com/s/FyuddlwRY7DsHUejCjiVug
边栏推荐
- 论文翻译英译中,怎样做翻译效果好?
- [ 英语 ] 语法重塑 之 动词分类 —— 英语兔学习笔记(2)
- MySQL is sorted alphabetically
- Simulation volume leetcode [general] 1062 Longest repeating substring
- 女生学软件测试难不难 入门门槛低,学起来还是比较简单的
- Delete the variables added to watch1 in keil MDK
- Black cat takes you to learn UFS protocol Chapter 18: how UFS configures logical units (Lu Management)
- MySQL5.72. MSI installation failed
- Past and present lives of QR code and sorting out six test points
- 电子书-CHM-上线CS
猜你喜欢

Suspended else

MySQL5.72. MSI installation failed

Delete the variables added to watch1 in keil MDK

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

Changes in the number of words in English papers translated into Chinese

Full link voltage measurement: building three models

Drug disease association prediction based on multi-scale heterogeneous network topology information and multiple attributes

LeetCode 729. My schedule I

org.activiti.bpmn.exceptions.XMLException: cvc-complex-type.2.4.a: 发现了以元素 ‘outgoing‘ 开头的无效内容

CS passed (cdn+ certificate) PowerShell online detailed version
随机推荐
org. activiti. bpmn. exceptions. XMLException: cvc-complex-type. 2.4. a: Invalid content beginning with element 'outgoing' was found
端午节快乐Wish Dragon Boat Festival is happy
模拟卷Leetcode【普通】1314. 矩阵区域和
Tms320c665x + Xilinx artix7 DSP + FPGA high speed core board
红蓝对抗之流量加密(Openssl加密传输、MSF流量加密、CS修改profile进行流量加密)
电子书-CHM-上线CS
On the first day of clock in, click to open a surprise, and the switch statement is explained in detail
The pit encountered by keil over the years
今日夏至 Today‘s summer solstice
LeetCode每日一题(971. Flip Binary Tree To Match Preorder Traversal)
Wish Dragon Boat Festival is happy
QT: the program input point xxxxx cannot be located in the dynamic link library.
Luogu p2141 abacus mental arithmetic test
LeetCode 732. My schedule III
An article was uncovered to test the truth of outsourcing companies
[ 英语 ] 语法重塑 之 英语学习的核心框架 —— 英语兔学习笔记(1)
CS certificate fingerprint modification
Cobalt Strike特征修改
模拟卷Leetcode【普通】1249. 移除无效的括号
A 27-year-old without a diploma, wants to work hard on self-study programming, and has the opportunity to become a programmer?