Validation of fields with same name and class get “TypeError: e.validator.methods[o] is undefined”

前端 未结 2 1296
耶瑟儿~
耶瑟儿~ 2020-12-20 06:35

I have this HTML code:


2条回答
  •  没有蜡笔的小新
    2020-12-20 07:12

    I had the same problem and the solution in your case would be the following.

    Plug-ins used:

    • http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/jquery.validate.min.js
    • http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.1/additional-methods.min.js

    HTML:

    
    
    

    JS:

    $("#form").validate({
        // Rules for form validation
        rules:
        {
            "field1[]":
            {
                require_from_group: [1, ".pprice-group"]
            }
        },
    
        // Messages for form validation
        messages:
        {
            "field1[]":
            {
                require_from_group: 'At least {0} field required'
            }
    
        }
    });
    

提交回复
热议问题