How to make select2 work with jquery.validation plugin?

后端 未结 15 609
北荒
北荒 2020-12-01 02:40

I\'m trying to validate select2 field using jquey.validation plugin but nothing happens.

I want to make select required field.

I\'m using this custom validat

15条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 03:28

    When you create a custom rule, you also must properly declare it. Since your custom rule depends on an argument, then you must pass the argument when declaring the rule

    rules: {
       country: {
           required: true,
           requiredcountry: "your argument here"  // <- declare the custom rule
       }
    }
    

提交回复
热议问题