0

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!

tereško
  • 58,060
  • 25
  • 98
  • 150
Amir Magdy
  • 188
  • 9
  • Why couldn't you just call the form's validate function (`$frm.validate()`), check if it's valid (`$frm.isvalid()`) then run your custom code afterwards? – von v. May 01 '13 at 02:40
  • this will not work on blur/key up of fields. as the validation currently works. – Amir Magdy May 01 '13 at 02:47

0 Answers0