//密码
var regex = new RegExp('(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{8,30}');
if(!regex.test(this.newPassword1)){
// this.$toast("密码必须同时包含大写、小写、数字和特殊字符其中三项且至少8位");
return;
}
//手机号
$("#mobile").blur(function () {
let _this = $(this).val();
let reg = /^1[3456789]d{9}$/;
if (_this === "" || _this == null) {
$(".span-text:eq(6)").html("该字段为必填字段");
} else if (!reg.test(_this)) {
$(".span-text:eq(6)").html("手机号码有误");
}else {
$(".span-text:eq(6)").html("");
}
});
官网:https://www.layui.com/demo/form.html
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46<script> //使用layui的表单校验 layui.use(['form'],function () { var form = layui.form; form.verify({ account: function(value, item){ //value:表单的值、item:表单的DOM对象 if(!new RegExp("^[a-zA-Z0-9_u4e00-u9fa5\s·]+$").test(value)){ return '登录名不能有特殊字符'; } if(/(^_)|(__)|(_+$)/.test(value)){ return '登录名首尾不能出现下划线'_''; } if(/^d+d+d$/.test(value)){ return '登录名不能全为数字'; } if(value.length >25){ return '登录名长度在1到25位之间'; } } ,password: function(value, item){ if(!new RegExp("(?=.*[0-9])(?=.*[a-zA-Z])(?=.*[^a-zA-Z0-9]).{6,30}").test(value)){ return '密码必须包含大小写字母、数字和特殊字符(长度大于6位)'; } } ,checkPass: function(value, item){ let _this = $("#checkPass").val(); let _password = $("#password").val(); if(_this !== _password){ return '与上次输入密码不同'; } } ,userName: function(value, item){ if(value.length >30){ return '长度在1到30位之间,中文算两个'; } } ,mobile: function(value, item){ let reg = /^1[3456789]d{9}$/; if(!reg.test(value)){ return '手机号码有误'; } } }); }) </script>
最后
以上就是勤恳毛衣最近收集整理的关于密码校验(密码必须同时包含大写、小写、数字和特殊字符其中三项且至少8位)的全部内容,更多相关密码校验(密码必须同时包含大写、小写、数字和特殊字符其中三项且至少8位)内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复