jQuery“验证不是函数"; [英] jQuery "Validation is not a function"

查看:65
本文介绍了jQuery“验证不是函数";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是此jQuery验证插件,并且很出名:

I'm using this jQuery validation plugin and getting the famous:

$(#Form").validate不是函数

$("#Form").validate is not a function

当尝试在Firebug中进行验证(以及所有其他浏览器中的等效消息)时.

when trying to validate in Firebug (and equivalent messages in all other browsers).

这意味着我试图在同时加载jquery-1.4.2.jsjquery.validate.js之前调用它.我已经使用Fiddler演示了在调用validate()之前正在 requested 这些文件,因此,在没有更好的方法的情况下,我只能假定这两个文件已完全加载到浏览器中.

This would imply that I'm attempting to call it before both jquery-1.4.2.js and jquery.validate.js are loaded. I've used Fiddler to show these files are being requested prior to calling validate() so in the absence of a better method I can only assume these two files are completely loaded within the browser.

我还有别的地方可以解决这个问题吗?如果首先请求了脚本,则还应该按该顺序加载它们吗?有办法找出答案吗?

Is there anywhere else I should look in order to solve this? If the scripts are requested first they should be also loaded in that order? Is there a way to find out?

我目前认为插件中存在其他原因(配置等).我到处搜索过,但似乎没有一种解决方案适用于我.

I'm currently of the opinion there is something else in the plugin causing this (config etc). I've searched all over but non of the solutions seem to apply to me.

有什么想法去哪里找?

我的jQuery是:

$(document).ready(function () {
    console.log("loaded");
    $("#Form").validate({
        rules: {
            container_0$centre_0$txtFirstName: { required: true }
        }
    });
})

,其形式为:

<form method="post" action="/url" id="Form" enctype="multipart/form-data">

 <div class="ctrlholder">
    <label for="firstname">First Name</label>
    <input name="container_0$centre_0$txtFirstName" type="text" id="txtFirstName" class="required" /><em>*</em>
    <div id="errFirstName" class="error" style="display:none;">Please enter your first name</div>
  </div>
</form>

有简化的代码版本.

推荐答案

看来,jquery.tools.min.js(似乎是

It appears that jquery.tools.min.js (which appears to be this) was causing the problem. On removing this I can validate as usual.

我将进一步调查,但我只有脚本的缩小版本,尽管我可能会猜测是因为它具有自己的验证,可能导致方法名称重叠.

I would investigate further but I only have the minified version of the script although I'd hazard a guess it's because it has its own validation, likely causing a method name overlap.

对于这种极端情况,这将是未来的绝佳资源.

This will be an excellent future resource for this edge case.

这篇关于jQuery“验证不是函数";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆