3cb1be7b by 任超

style:注册

1 parent d77a1b70
Pipeline #2 for 3cb1be7b failed in 0 seconds
...@@ -13,7 +13,7 @@ function SetServicesPath() { ...@@ -13,7 +13,7 @@ function SetServicesPath() {
13 //设置全局參數 13 //设置全局參數
14 var portal = 14 var portal =
15 { 15 {
16 'api_url': "http://192.168.2.108:81/api", //属性名用引号括起来,属性间由逗号隔开 16 'api_url': "http://192.168.2.59:8000", //属性名用引号括起来,属性间由逗号隔开
17 'name': 'myName' 17 'name': 'myName'
18 }; 18 };
19 19
......
1 $(function () { 1 $(function () {
2 layui.use(['form'], function () { 2 layui.use(['form'], function () {
3 var form = layui.form 3 var form = layui.form
4 // 校验
5 form.verify({
6 username: function (value, item) {
7 if(value=='') {
8 return '用户名不能为空';
9 }
10 //value:表单的值、item:表单的DOM对象
11 if (!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)) {
12 return '用户名不能有特殊字符';
13 }
14 if (/(^\_)|(\__)|(\_+$)/.test(value)) {
15 return '用户名首尾不能出现下划线\'_\'';
16 }
17 if (/^\d+\d+\d$/.test(value)) {
18 return '用户名不能全为数字';
19 }
20
21 //如果不想自动弹出默认提示框,可以直接返回 true,这时你可以通过其他任意方式提示(v2.5.7 新增)
22 if (value === 'xxx') {
23 alert('用户名不能为敏感词');
24 return true;
25 }
26 },
27 code: [
28 /^[\S]{4,6}$/
29 , '验证码必须4到6位,且不能出现空格'
30 ],
31 //我们既支持上述函数式的方式,也支持下述数组的形式
32 //数组的两个值分别代表:[正则匹配、匹配不符时的提示文字]
33 });
34
35 form.on('select(type)', function (data) { 4 form.on('select(type)', function (data) {
36 console.log(data); 5 console.log(data);
37 }) 6 })
...@@ -53,15 +22,15 @@ function register(formData) { ...@@ -53,15 +22,15 @@ function register(formData) {
53 url: portal.api_url + "/protal/users/insert",//路径 22 url: portal.api_url + "/protal/users/insert",//路径
54 type:"post", 23 type:"post",
55 dataType:"json", 24 dataType:"json",
56 data : formData, 25 contentType: 'application/json',
26 data : JSON.stringify(formData),
57 //数据,这里使用的是Json格式进行传输 27 //数据,这里使用的是Json格式进行传输
58 success: function (result) {//返回数据根据结果进行相应的处理 28 success: function (result) {//返回数据根据结果进行相应的处理
59 if (result.code == 200 && result.data != null) { 29 if (result.code == 200 && result.data != null) {
60 console.log(result.data)
61 layui.use('layer', function () { 30 layui.use('layer', function () {
62 layer.msg('注册成功!'); 31 layer.msg('注册成功!');
63 }) 32 })
64 // window.open("../index.html","_self") 33 window.open("../index.html","_self")
65 } 34 }
66 } 35 }
67 }); 36 });
......
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
17 17
18 <body> 18 <body>
19 <div class="register"> 19 <div class="register">
20 <form class="layui-form login_form" action=""> 20 <form class="layui-form login_form">
21 <div class="layui-form-item"> 21 <div class="layui-form-item">
22 <h1 class="register_title">注册</h1> 22 <h1 class="register_title">注册</h1>
23 </div> 23 </div>
24 <div class="layui-form-item"> 24 <div class="layui-form-item">
25 <label class="layui-form-label">姓名</label> 25 <label class="layui-form-label">姓名</label>
26 <div class="layui-input-block"> 26 <div class="layui-input-block">
27 <input type="text" name="username" required lay-verify="username" placeholder="请输入姓名" class="layui-input"> 27 <input type="text" name="username" placeholder="请输入姓名" class="layui-input">
28 </div> 28 </div>
29 </div> 29 </div>
30 30
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
40 <div class="layui-form-item"> 40 <div class="layui-form-item">
41 <label class="layui-form-label">身份证</label> 41 <label class="layui-form-label">身份证</label>
42 <div class="layui-input-block"> 42 <div class="layui-input-block">
43 <input type="text" name="idcard" required lay-verify="identity" placeholder="请输入身份证" class="layui-input"> 43 <input type="text" name="idcard" placeholder="请输入身份证" class="layui-input">
44 </div> 44 </div>
45 </div> 45 </div>
46 46
...@@ -53,20 +53,20 @@ ...@@ -53,20 +53,20 @@
53 <div class="layui-form-item"> 53 <div class="layui-form-item">
54 <label class="layui-form-label">密码</label> 54 <label class="layui-form-label">密码</label>
55 <div class="layui-input-block"> 55 <div class="layui-input-block">
56 <input type="password" lay-verify="pass" placeholder="请输入密码" class="layui-input"> 56 <input type="password" placeholder="请输入密码" class="layui-input">
57 </div> 57 </div>
58 </div> 58 </div>
59 <div class="layui-form-item"> 59 <div class="layui-form-item">
60 <div class="layui-inline"> 60 <div class="layui-inline">
61 <label class="layui-form-label">手机号</label> 61 <label class="layui-form-label">手机号</label>
62 <div class="layui-input-block"> 62 <div class="layui-input-block">
63 <input type="tel" maxlength="11" required lay-verify="phone" name="phone" placeholder="请输入手机号" class="layui-input"> 63 <input type="tel" maxlength="11" name="phone" placeholder="请输入手机号" class="layui-input">
64 </div> 64 </div>
65 </div> 65 </div>
66 <div class="layui-inline"> 66 <div class="layui-inline">
67 <label class="layui-form-label">验证码</label> 67 <label class="layui-form-label">验证码</label>
68 <div class="layui-input-block"> 68 <div class="layui-input-block">
69 <input type="tel" maxlength="666" required lay-verify="code" name="code" placeholder="请输入验证码" class="layui-input"> 69 <input type="tel" maxlength="666" name="code" placeholder="请输入验证码" class="layui-input">
70 </div> 70 </div>
71 </div> 71 </div>
72 </div> 72 </div>
...@@ -83,3 +83,4 @@ ...@@ -83,3 +83,4 @@
83 <script src="../staticLib/jquery/jquery.min.js"></script> 83 <script src="../staticLib/jquery/jquery.min.js"></script>
84 <script src="../staticLib/layui/layui.js"></script> 84 <script src="../staticLib/layui/layui.js"></script>
85 <script src="../staticJs/register.js"></script> 85 <script src="../staticJs/register.js"></script>
86 <script src="../staticJs/common.js"></script>
...\ No newline at end of file ...\ No newline at end of file
......