当前位置:网站首页>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
边栏推荐
猜你喜欢

Address bar parameter transmission of list page based on jeecg-boot

Today's summer solstice

Phishing & filename inversion & Office remote template

How much is the price for the seal of the certificate

Financial German translation, a professional translation company in Beijing

On the first day of clock in, click to open a surprise, and the switch statement is explained in detail

Esp32 esp-idf watchdog twdt

Play video with Tencent video plug-in in uni app

Postman core function analysis - parameterization and test report

How to translate biomedical instructions in English
随机推荐
Remember the implementation of a relatively complex addition, deletion and modification function based on jeecg-boot
Simulation volume leetcode [general] 1062 Longest repeating substring
University of Manchester | dda3c: collaborative distributed deep reinforcement learning in swarm agent systems
查询字段个数
How much is it to translate Chinese into English for one minute?
JDBC requset corresponding content and function introduction
mysql按照首字母排序
私人云盘部署
[mqtt from getting started to improving series | 01] quickly build an mqtt test environment from 0 to 1
Black cat takes you to learn UFS protocol Chapter 4: detailed explanation of UFS protocol stack
Advanced MySQL: Basics (1-4 Lectures)
模拟卷Leetcode【普通】1249. 移除无效的括号
模拟卷Leetcode【普通】1414. 和为 K 的最少斐波那契数字数目
英语论文翻译成中文字数变化
SQL Server manager studio(SSMS)安装教程
Esp32 esp-idf watchdog twdt
Is the test cycle compressed? Teach you 9 ways to deal with it
CS-证书指纹修改
Today's summer solstice
Drug disease association prediction based on multi-scale heterogeneous network topology information and multiple attributes