Bootstrap validator resetForm

16,716

Solution 1

It is simple, you just only need to add

excluded: [':disabled'],

Into validation init.

Example:

    $('#emailForm').bootstrapValidator({
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        excluded: [':disabled'],
        fields: {
            email: {
                validators: {
                    emailAddress: {
                        message: 'The value is not a valid email address'
                    }
                }
            }
        }
    });

Solution 2

I know this is very old.

$("#emailForm").data('bootstrapValidator').resetForm();

Resets the form validation, but will not clear the fields. Which is fine in my case. Using one form for multiple customers. Easier for the visitor to have their name and email left there, but just retype the message. So I just clear message field.

Share:
16,716

Related videos on Youtube

Nk SP
Author by

Nk SP

Updated on June 04, 2022

Comments

  • Nk SP
    Nk SP about 2 years

    I am using bootstrapvalidator with Bootstrap 3.3
    I need to reset a form in a modal dialog.
    I used the right method but it does not work into the modal dialog.

     $('#emailForm').bootstrapValidator("resetForm",true); 
    

    If I open the modal and insert an email, and then try to reset the form, the validation controls are still there.

    JSFiddle

  • 3y3skill3r
    3y3skill3r over 9 years
    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 fields/validators initialized with HTML attributes might be ignored.