How to make select2 work with jquery.validation plugin?

后端 未结 15 580
北荒
北荒 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:21

    $("select.select2-me").each(function(index, el) {
    
        if ($(this).is("[data-rule-required]") && 
        $(this).attr("data-rule-required") == "true") {
            $(this).on('select2-close', function(e) {
                $(this).valid()
            });
        }
    });
    

    work for me.

提交回复
热议问题