BootstrapValidator无法提交表单!

芸复山人 2016-05-18 05:11:49
js代码:
$(document).ready(function() {
// Invoke the plugin
//$('input, textarea').placeholder();
$('#register')
.bootstrapValidator({
message: 'This value is not valid',
//live: 'submitted',
submitButtons: 'button[type="submit"]',
submitHandler: null,
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
name: {
message: '用户名无效',
validators: {
notEmpty: {
message: '用户名不能位空'
},
stringLength: {
min: 6,
max: 30,
message: '用户名必须大于6,小于30个字'
},
regexp: {
regexp: /^[a-zA-Z0-9_\.]+$/,
message: '用户名只能由字母、数字、点和下划线组成'
},
remote: {
url: '#',
message: '用户名不可用'
},
different: {
field: 'password',
message: '用户名和密码不能相同'
}
}
},
email: {
validators: {
notEmpty: {
message: '邮箱不能为空'
},
emailAddress: {
message: '输入不是有效的电子邮件地址'
}
}
},
password: {
validators: {
notEmpty: {
message: '密码不能位空'
},
stringLength: {
min: 6,
max: 30,
message: '密码必须大于6,小于30个字符且不能与用户名相同'
},
identical: {
field: 'confirmPassword',
message: '两次密码不一致'
},
different: {
field: 'name',
message: '用户名和密码不能相同'
}
}
},
confirmPass: {
validators: {
notEmpty: {
message: '密码不能为空'
},
identical: {
field: 'password',
message: '两次密码不一致'
},
different: {
field: 'name',
message: '用户名和密码不能相同'
}
}
}
}
})
.on('success.form.bv', function(e) {
alert(e);
// Prevent submit form
/* e.preventDefault();

var $form = $(e.target),
validator = $form.data('bootstrapValidator');


$('#register').submit(); */
});
});


html:
<form id="register" class="form-signin" action="${ctx}/sys/user/userSave" method="post">
<div class="form-group">
<label class="input-label" for="user">用户名</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" class="form-control input-large" name="name" id="user" placeholder="输入用户名" title="注册用户名长度为6-20个字符">
<!-- <span class="help-inline"><font color="red">*</font> </span> -->
</div>
</div><br/>

<div class="form-group">
<label for="email">邮箱</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input type="email" class="form-control required" id="email" name="email" placeholder="输入邮箱账号" title="邮箱正确格式:test@189.cn">
</div>
</div><br/>

<div class="form-group">
<label for="pass1">密码</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control input-large required" name="password" id="password" placeholder="输入密码" title="用户名长度为6-30个字符">
<!-- <span class="input-group-addon"><span id="seePass1" class="glyphicon glyphicon-eye-close" style="cursor: pointer"></span></span> -->
</div>
</div><br/>
<div class="form-group">
<label for="pass2">确认密码</label>
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
<input type="password" class="form-control required" id="confirmPass" name="confirmPass" placeholder="重复输入密码" title="输入与上面相同的密码">
<!-- <span class="input-group-addon"><span id="seePass2" class="glyphicon glyphicon-eye-close" style="cursor: pointer"></span></span> -->
</div>
</div><hr/>
<div class="form-group">
<button id="reg" class="btn btn-primary btn-lg btn-block" type="submit">注册</button>    

<div class="checkbox"> 已有账号?
<label style="padding-left: 0"><a href="javascript:history.go(-1);" >直接登录»</a></label>
</div>
</div>



点击提交后,on里alert没有打印,大神指点下,谢谢!!
...全文
1027 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_31349245 2017-10-31
  • 打赏
  • 举报
回复
参数 描述 默认值 defaultSubmit 默认提交表单 用这个id就行
淡淡的id 2017-04-22
  • 打赏
  • 举报
回复
remote: { url: '#', message: '用户名不可用' } 因为你这个总是验证不通过,所以去掉这个就行了
无敌飞哥哥 2017-03-31
  • 打赏
  • 举报
回复
同样遇到这种提交不成功的问题,求大侠指导,十分感谢!!!
LZ_MZ 2016-06-29
  • 打赏
  • 举报
回复
与到相同问题,求楼主分享下解决方案~

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧