This site contains the document for old version. Please upgrade to the latest version v1.0.0

Validating a form placed inside a Bootstrap modal

Examples

It's possible to use the plugin with a form which is placed inside a Bootstrap Modal.

By default, the plugin will not initialize the fields which are disabled, hidden, or not visible. Since the form is placed inside a model which is not visible after loading page, the plugin might ignore the fields.

That's the reason why we need to set excluded: ':disabled'. Take a look at the excluded setting for more information.

$(document).ready(function() {
    $('#loginForm').formValidation({
        message: 'This value is not valid',
        excluded: ':disabled',
        ...
    });
});

Resetting form when showing the modal

If you want to reset all the fields in form whenever the modal is shown, the resetForm() method will help you:

$('#loginModal').on('hidden.bs.modal', function() {
    $('#loginForm').formValidation('resetForm', true);
});

Related examples