Custom Validator - Check whether form is valid

Custom Validator - Check whether form is valid

I've created my own custom validator, each time an element is validated and returns true I would like to test whether the form is valid. I'm also dynamically turning validation off on certain properties depending on the applications current configuration so i need this to be dynamic also.

I've tried calling the .valid() method and the .validate().form() method but both result in an error "too much recursion". I guess this i because calling these result in an infinite loop as it causes my custom validator method to be called again. Is there a way around this or another method I could call to check the form is valid? I've copied some code below.

        jQuery.validator.addMethod('taskrequired', function (value, element, params) {
            if ((params.active == 1) && (value == ''))
                return false;
            else {

                validateView();

                return true;
            }
        }, '');

        jQuery.validator.unobtrusive.adapters.add('taskrequired', ['active'], function (options) {
            options.rules['taskrequired'] = { active: options.params.active };
            options.messages['taskrequired'] = options.message;
        });

          function validateView() {

            if ($("#form0").validate().form())
            {
                alert('Form Valid');
            }
            else
            {
                alert('Form Not Valid');

            }
    }

Thanks