how to run custom code after validation of mvc4 unobtrusive validation?

227 Views Asked by At

i am looking of the a way to run custom code after validation of mvc4 unobtrusive validation functionality i have found a lot but nothing works for me try this

    var settngs = $.data($('form')[0], 'validator').settings;
    var oldErrorFunction = settngs.errorPlacement;
    var oldSucessFunction = settngs.success;
    settngs.errorPlacement = function (error, inputElement) {
        $(inputElement).closest('.fieldset').addClass('fieldset-validation-error')
        oldErrorFunction(error, inputElement);
        myadditionalfunction();
    }
    settngs.success = function (error) {
        $(error).closest('.fieldset').removeClass('fieldset-validation-error')
        oldSucessFunction(error);
        myadditionalfunction();
    }

didn't work i also tried

    $.validator.setDefaults({
        invalidHandler: function (form) {
            myadditionalfunction();
        }
    });

also didn't work and i am going crazy if u have fixed it please let me know

my custom functions will not hit!

0

There are 0 best solutions below