简体   繁体   English

jQuery(...)。validate不是函数

[英]jQuery (…).validate is not a function

My browser console is telling me that: 我的浏览器控制台告诉我:

$(...).validate is not a function

I am simply trying to reproduce this example , but it is not working, and I've no idea why. 我只是想重现该示例 ,但它不起作用,我也不知道为什么。 Looking at the networking console, I see that there is no file load error. 查看网络控制台,我发现没有文件加载错误。 Also my cache is clear and turned off, so I should be looking at the right source. 另外,我的缓存是清除的并且已关闭,因此我应该寻找正确的源。 What else could be going wrong? 还有什么可能出问题了?

Here's the full code on the page: 这是页面上的完整代码:

<form id="myform">
    <input type="text" name="field1" />
    <br/>
    <input type="text" name="field2" />
    <br/>
    <input type="submit" />
</form>


<script src="jquery-1.8.3.min.js"></script> 

<script>

$(document).ready(function () {

    $('#myform').validate({ // initialize the plugin
        rules: {
            field1: {
                required: true,
                email: true
            },
            field2: {
                required: true,
                minlength: 5
            }
        },
        submitHandler: function (form) { // for demo
            alert('valid form submitted'); // for demo
            return false; // for demo
        }
    });

});


</script>

You need to include jQuery validation plugin: 您需要包括jQuery验证插件:

<script type="text/javascript" src="path-to/jquery-validate.js"></script>

download it and attach to your project. 下载并附加到您的项目。

您所指向的示例使用jQuery validate插件 ,但尚未将其包含在示例中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM