开发者

How to have Multiple Validation Rulesets with jQuery Validation

开发者 https://www.devze.com 2023-02-03 14:27 出处:网络
I have a multi-part form with three different sets of validat开发者_运维百科ion (each fieldset). Each validation ruleset is defined such as:

I have a multi-part form with three different sets of validat开发者_运维百科ion (each fieldset). Each validation ruleset is defined such as:

var paymentValidation =
    {
        rules: {
            "cardInfo.NameOnCard": {
                required: true
            },
            ...
        }
        messages: { .... }

and then when I need to validate a specific rulset, I am trying to use

var validator = $(form).validate(paymentValidation)
if(validator.valid()) {....}

Except it appears that once I perform validation once with a ruleset, the other optionsets I pass in do not matter.

I've seen articles suggesting that I can validate the entire form and then check each fieldset. While that approach technically works I end up with validation messages for elements outside of my desired scope.

So I'm trying to figure out how to go about performing validation with various sets of rules. Any help would be greatly appreciated - thanks!


This: http://www.zachhunter.com/2010/06/jquery-validation-with-asp-net/ worked for me. Cheers.

0

精彩评论

暂无评论...
验证码 换一张
取 消