views:

99

answers:

0

Alright folks:

I've got my own custom JQuery validation being called through $('#aspnetForm').submit()

Unfortunately, this means the validation gets called no matter what validation group the control being validated belongs to. Can anyone think of a good way to bypass this problem?

I can access the Validation Group (in theory) via the attr('onClick') of the callee, however this would require me to know which button called the postback, and I'm not sure that is possible. Also, this access would require some Regex which is both a bit slow and slightly unreliable, so I'd like to avoid that if possible!

Cheers, Ed

EDIT

Apparently, some code would help explain:

This is how I'm doing the validation:

    $('#aspnetForm').submit(function () {
        return doValidation(clientID);  // returns false if the input is not valid, clientID is inserted by the server when the script is created.
    });

The onclick method of an ASP input looks like: (line breaks added for clarity)

    javascript:WebForm_DoPostBackWithOptions(
        new WebForm_PostBackOptions(
            "ctl00$ContentPlaceHolder1$NewOk",  /// ASP.net's name for the control (also held in the 'name' property)
            "",
            true,
            "NewCall",  /// this is the validation group
            "",
            false,
            false)
    )

I'd like to be able to do the following:

    $('#aspnetForm').submit(function () {
        var validationGroup = GetControlValidationGroup(clientID);
        var postersValidationGroup = GetCurrentValidationGroup();
        if (validationGroup == postersValidationGroup) {
            return doValidation(clientID);
        }
    });