2

My question is quite simple :

How to set dependency on a field and set params to the rule function ? What's the key to set params in ?

$('#form').validate({
    rules: {
        somefield: {
            minlength: {
                depends: function() {
                    return $('#checkbox').prop('checked');
                }, 
                keyToSetParams??: 5
            }
        }
    }
});

Without dependency, it would look like this :

$('#form').validate({
    rules: {
        somefield: {
            minlength: 5
        }
    }
});

1 Answer 1

2

I found the solution after some debugging, the key name is "param" so it look like:

$('#form').validate({
    rules: {
        somefield: {
            minlength: {
                depends: function() {
                    return $('#checkbox').prop('checked');
                }, 
               param: 5
            }
        }
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

I thought this wasn't possible.. didn't work when i tried. I must have done something wrong :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.