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