resetField()

Reset the field

This method also clears all the messages, hide the feedback icons, etc.

resetField(field: String, reset: Boolean): Core

* presents a required parameter

  • field * — The field name
  • reset — If true, the method resets field value to empty or remove checked, selected attributes

Example: Clearing field when clicking the icon

The following example shows how to clear the field when clicking the feedback icon.


const fv = FormValidation.formValidation(
    document.getElementById('demoForm'),
    {
        fields: {
            ...
        },
        plugins: {
            ...
            icon: new FormValidation.plugins.Icon({
                valid: 'fa fa-check',
                invalid: 'fa fa-times',
                validating: 'fa fa-refresh',
                onPlaced: function(e) {
                    // e.field is the field name
                    // e.iconElement presents the icon element

                    e.iconElement.addEventListener('click', function() {
                        // Reset field when clicking on the associated icon
                        fv.resetField(e.field);
                    });
                },
            }),
        },
    }
);