如何在引导程序验证中按下取消按钮时隐藏模态

how to hide a modal when cancel button pressed in bootstrapvalidation

$( 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);
    });
    });

这是我的代码的一部分。这里如何在 bootstrap 验证插件中按下取消按钮时关闭模式以及如何清除 bootstrap 验证插件中的 formfild 值?

我不确定这是否是您要找的东西,但无论如何我建议您访问 bootstrap 网站 http://getbootstrap.com/css/

在那里你会找到一个交叉删除按钮:

<button type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>

这个关闭按钮可能就是您要找的:

 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>