3cb1be7b by 任超

style:注册

1 parent d77a1b70
Pipeline #2 for 3cb1be7b failed in 0 seconds
......@@ -13,7 +13,7 @@ function SetServicesPath() {
//设置全局參數
var portal =
{
'api_url': "http://192.168.2.108:81/api", //属性名用引号括起来,属性间由逗号隔开
'api_url': "http://192.168.2.59:8000", //属性名用引号括起来,属性间由逗号隔开
'name': 'myName'
};
......
$(function () {
layui.use(['form'], function () {
var form = layui.form
// 校验
form.verify({
username: function (value, item) {
if(value=='') {
return '用户名不能为空';
}
//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 '用户名不能全为数字';
}
//如果不想自动弹出默认提示框,可以直接返回 true,这时你可以通过其他任意方式提示(v2.5.7 新增)
if (value === 'xxx') {
alert('用户名不能为敏感词');
return true;
}
},
code: [
/^[\S]{4,6}$/
, '验证码必须4到6位,且不能出现空格'
],
//我们既支持上述函数式的方式,也支持下述数组的形式
//数组的两个值分别代表:[正则匹配、匹配不符时的提示文字]
});
form.on('select(type)', function (data) {
console.log(data);
})
......@@ -53,15 +22,15 @@ function register(formData) {
url: portal.api_url + "/protal/users/insert",//路径
type:"post",
dataType:"json",
data : formData,
contentType: 'application/json',
data : JSON.stringify(formData),
//数据,这里使用的是Json格式进行传输
success: function (result) {//返回数据根据结果进行相应的处理
if (result.code == 200 && result.data != null) {
console.log(result.data)
layui.use('layer', function () {
layer.msg('注册成功!');
})
// window.open("../index.html","_self")
window.open("../index.html","_self")
}
}
});
......
......@@ -17,14 +17,14 @@
<body>
<div class="register">
<form class="layui-form login_form" action="">
<form class="layui-form login_form">
<div class="layui-form-item">
<h1 class="register_title">注册</h1>
</div>
<div class="layui-form-item">
<label class="layui-form-label">姓名</label>
<div class="layui-input-block">
<input type="text" name="username" required lay-verify="username" placeholder="请输入姓名" class="layui-input">
<input type="text" name="username" placeholder="请输入姓名" class="layui-input">
</div>
</div>
......@@ -40,7 +40,7 @@
<div class="layui-form-item">
<label class="layui-form-label">身份证</label>
<div class="layui-input-block">
<input type="text" name="idcard" required lay-verify="identity" placeholder="请输入身份证" class="layui-input">
<input type="text" name="idcard" placeholder="请输入身份证" class="layui-input">
</div>
</div>
......@@ -53,20 +53,20 @@
<div class="layui-form-item">
<label class="layui-form-label">密码</label>
<div class="layui-input-block">
<input type="password" lay-verify="pass" placeholder="请输入密码" class="layui-input">
<input type="password" placeholder="请输入密码" class="layui-input">
</div>
</div>
<div class="layui-form-item">
<div class="layui-inline">
<label class="layui-form-label">手机号</label>
<div class="layui-input-block">
<input type="tel" maxlength="11" required lay-verify="phone" name="phone" placeholder="请输入手机号" class="layui-input">
<input type="tel" maxlength="11" name="phone" placeholder="请输入手机号" class="layui-input">
</div>
</div>
<div class="layui-inline">
<label class="layui-form-label">验证码</label>
<div class="layui-input-block">
<input type="tel" maxlength="666" required lay-verify="code" name="code" placeholder="请输入验证码" class="layui-input">
<input type="tel" maxlength="666" name="code" placeholder="请输入验证码" class="layui-input">
</div>
</div>
</div>
......@@ -82,4 +82,5 @@
</html>
<script src="../staticLib/jquery/jquery.min.js"></script>
<script src="../staticLib/layui/layui.js"></script>
<script src="../staticJs/register.js"></script>
\ No newline at end of file
<script src="../staticJs/register.js"></script>
<script src="../staticJs/common.js"></script>
\ No newline at end of file
......