jQuery validation - required working but accept not

后端 未结 3 1431
伪装坚强ぢ
伪装坚强ぢ 2021-01-05 17:33

im uploading an image and trying to validate it before with jquery. Here is my code:



        
3条回答
  •  无人及你
    2021-01-05 18:06

    1) As already stated, you need to include the additional-methods.js file.

    2) For file extensions, use the extension rule. The accept rule is for mime types.

    $(document).ready(function(){
    
        $("#form").validate({
            errorLabelContainer: "#message_box", wrapper: "li",
            rules: {
                image: {
                    required: true,
                    extension: "jpg|jpeg|png|gif"
                }
            },
            ...
        })
    
    });
    

提交回复
热议问题