未捕获的TypeError:无法调用未定义的jquery validate的方法’call’

我的表格如下

Description of the Image:
Files / Image:

X-ray / Site / Document / Agreement etc.

脚本如下。

 $(document).ready(function () { $("#new_image").dialog({ height: $("#new_image").height() + 150, width: $("#new_image").width() - 450, modal: true, autoOpen: false, show: { effect: "fade", duration: 200 }, hide: { effect: "fade", duration: 200 }, buttons: { "Submit": function () { $("#new_image_form").submit(); }, "Close": function () { $('#new_image').dialog("close"); } } }); $('#new_image_form').validate({ rules: { desc: { required: true, minlength: 10 }, image: { required: true, accept: "image/*" } }, messages: { image: { required: "only Image files accepted", accept: "Please upload only image", }, }, submitHandler: function (form) { $('#new_image_form').ajaxSubmit({ success: function (data) { console.log(data); $('#new_image').dialog("close"); $(':input', '#new_image_form') .not(':button, :submit, :reset, :hidden') .val('') .removeAttr('checked') .removeAttr('selected'); } }); parse_patients(); } }); $('#new_image').dialog("open"); }); 

我在js小提琴上有这个代码

http://jsfiddle.net/rakeshpatil1983/ctL7q/

当我实际将图像文件放在chrome浏览器控制台上时单击提交时出现错误

未捕获的TypeError:无法调用未定义的方法’call’

我无法解决这个问题。 此代码似乎适用于其他一些页面。

在#new_image_form的规则中,“accept”不是默认的jQuery Validator默认规则。 您必须使用以下默认规则之一: Jquery Validate – 类列表或定义您自己的自定义规则,如: jQuery Validate Plugin – 如何创建简单的自定义规则?

编辑:从下面的评论:有一个名为accept的规则是jQuery Validate插件包的一部分。 您只需要包含additional-methods文件即可使用它。

 //Add New Validator Rule jQuery.validator.addMethod("accept", function(value, element, param) { return value.match(new RegExp("^" + param + "$")); }); 

我有类似的问题,“接受”规则在开始时就忘记了。

然后’Uncaught TypeError:无法调用方法’未定义的’调用’消失了。