0
$(document).ready(function() {
$("#login-link").on("click", function() {
$("#login-modal").modal("show");
});
$('#loginform')
.bootstrapValidator({
excluded: ':disabled',
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
username: {
validators: {
notEmpty: {
message: 'The username is required'
}
}
},
password: {
validators: {
notEmpty: {
message: 'The password is required'
}
}
}
}
})
.on('success.form.bv', function (e) {
// Prevent form submission
e.preventDefault();
// Get the form instance
var $form = $(e.target);
// Get the BootstrapValidator instance
var bv = $form.data('bootstrapValidator');
// Use Ajax to submit form data
$.post($form.attr('action'), $form.serialize(), function(result) {
if(result=="success")
{
window.location = "home.php";
}
else
{
alert("wrong username or password");
}
}, 'json');
$('#login-modal').modal('hide');
});
$('#login-modal')
.on('shown.bs.modal', function() {
$('#loginform').find('[name="username"]').focus();
})
.on('hidden.bs.modal', function() {
$('#loginform').bootstrapValidator('resetForm', true);
});
});
这是我的代码的一部分。这里如何在bootstrapvalidation插件中按下取消按钮时关闭模式,以及如何清除bootstrapvalidation插件中的formfild值?如何在自举验证中按下取消按钮时隐藏模式
多数民众赞成在ok.this我知道它。我想要的是..我有2个按钮在模态内的形式,当我按取消模型应该关闭,当我按提交表单应提交,如果它包含任何错误,它应该验证。但现在如果我按取消也验证工作,而不是这个模态应该关闭 – vinay
谢谢。第二个为我工作..数据 - 解雇 – vinay
你能比请提交我的答案:) – Joh