javascript - "$(...).validate is not a function"即使我直接将 jquery.validate.js 代码放在 head 中

标签 javascript jquery validation

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">         </script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>
<script>
    $(document).ready(function () {
        $("#signupform").validate({
            rules:{
                email: {
                    required: true,
                    minlength: 10
                },
                password: {
                    required: true
                },
                password2: {
                    equalTo: "#password"
                }
            },
            messages: {
                email: "test"
            }
        });
    });
</script>

上面是我的代码,用于调用我放置在 . 它一直说 $(...).validate 不是一个函数。

然后,我删除了这个:

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js"></script>

我直接将访问“http://ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.js”得到的js代码放入<script></script>内的头部, 验证方法应该现在必须存在, 但是,我仍然得到 $(...).validate 不是一个函数。

有人知道是什么原因导致这里出现问题吗?

最佳答案

非常感谢您的评论。

花了几个小时我终于找到了这个问题的原因: 应用了 sitemesh,它会自动在主体底部添加一个 jquery 脚本链接,从而使结果页面添加了 2 个 jquery,而我无法仅通过查看中的代码来找到添加的这个邪恶的额外 jquery。 IDE。

关于javascript - "$(...).validate is not a function"即使我直接将 jquery.validate.js 代码放在 head 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38238505/

相关文章:

javascript - 检查字符串是否包含 'abc' 或 'cde' 开 Jest

jquery - 如果没有可见的 sibling ,则隐藏

java - 使用 Play 将验证错误作为 JSON 返回!框架

Excel VBA 数据验证 - 下拉 : Options too many to be saved, 导致错误 "Excel found unreadable content"

ajax - 验证使用 yii 中的 renderPartial 呈现的表单

javascript - 如何设置 VS2015 在我搞乱 JavaScript 时抛出错误?

javascript - setInterval() 中的 .load 调用只工作一次

javascript - Angular Controller 逻辑与 Vanilla JS 逻辑

javascript - jquery mouseover 事件触发两次

javascript - 如何创建带有滚动背景图像的可滚动文本区域?