Reputation: 25
$( 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);
});
});
This is part of my code. here how to close the modal when cancel button is pressed in bootstrapvalidation plugin and how to clear the formfild values in bootstrapvalidation plugin?
Upvotes: 0
Views: 307
Reputation: 166
I am not shure if that is what you are looking for but anywhay I would recomend to go on the bootstrap site http://getbootstrap.com/css/
there you will find a cross delete button:
<button type="button" class="close" aria-label="Close"><span aria-hidden="true">×</span></button>
and this close button, might be what you were looking for:
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
Upvotes: 2