0

我正在寻找一种在验证 mvc4 不显眼的验证功能后运行自定义代码的方法,我发现了很多但对我没有任何作用试试这个

    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();
    }

没用我也试过

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

也没有工作,如果你修好了,我会发疯的,请告诉我

我的自定义功能不会命中!

4

0 回答 0