user785436
user785436

Reputation: 19

jQuery conditional validation for minlength and maxlength

I am using jQuery validation plugin and this question is about conditional validation of minlength and maxlength rules.

I have a dropdown list and a textbox. If the user selects a particular value in dropdown list the textbox minlength should be 13 characters,maxlength should be 19 characters. For other dropdown values minlength and maxlength should be 16 characters.

Help appreciated. Thanks a lot

Upvotes: 1

Views: 1598

Answers (1)

Mahesh KP
Mahesh KP

Reputation: 6446

you can try like this

rules:
 {
     ControlName:
      {
          minlength:function (element) {
              you can write your code to check your conditions
          }
      }
 }

Upvotes: 2

Related Questions