Skip to content

Latest commit

 

History

History
37 lines (33 loc) · 833 Bytes

File metadata and controls

37 lines (33 loc) · 833 Bytes

3.11 onValidate callback

To add an extra action that will be run after the validation:

$('form#user').jsFormValidator({
    onValidate: function(errors, event) {
        // event - a form submittion event
        // errors - an object that looks like:
        /*
        errors = {
            element_1_id: {
                source_1_id: ['error_1', 'error_2', 'error_3'],
                source_2_id: ['error_4', 'error_5']
            },
            element_2_id: {
                ...
            },
            ...
        }
        */

        // Here your code
    }
});

Pure Javascript:

var field = document.getElementById('user');
FpJsFormValidator.customize(field, {
    onValidate: function(errors, event) {
        ...
    }
});

NB: this option should be defined for the parent form element