jQuery validate插件无法以MVC形式运行 [英] jQuery validate plugin is not working in MVC form

查看:64
本文介绍了jQuery validate插件无法以MVC形式运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的MVC表单

<head>    
    <script src="~/Scripts/jquery-1.8.3.js"></script>
    <script src="~/Scripts/jquery.validate.js"></script>
</head>
    <body>
        <form action="" method="get" id="login">
            <input id="email" class="text required email" type="text">
            <input type="submit" value="Login...">
        </form>
        <script>
            $(function () {
               $("#login").validate()
            });
        </script>
    </body>

但是由于某些原因,当我单击提交"按钮时,jQuery验证无法正常工作,并且出现了这样的错误

but for some reason when i click on the submit button the jquery validate is not working and i get an error like this

未捕获的TypeError:$(...).validate不是函数

Uncaught TypeError: $(...).validate is not a function

,但是当我在普通html页面中使用相同的html 以及指向相同脚本的链接时,我能够验证文本框.我是否缺少MVC中的某些内容,我是否必须启用/禁用MVC中的任何属性. 我在做什么错,请帮忙. 谢谢

but when i use the same html in a normal html page along with the link to the same script, i am able to validate the textbox. am i missing something in MVC should i have to enable/disable any properties in MVC. What am i doing wrong, please help. Thank you

推荐答案

真的是我的错误!!! 当我使用inspect元素时,我发现正在加载两个jquery插件,当我缩小原因时,是我不知不觉地在_ViewStart.cshtml页面中加载了另一个jquery插件. 我想分享这一点,所以其他人可以节省一天. 谢谢 @Shyju感谢您的帮助

really my mistake !!! when i used inspect element, i found there is two jquery plugin which was being loaded and when i narrow down the cause it was me who was unknowingly loading another jquery plugin in the _ViewStart.cshtml page. thought to share this, so somebody else could save the day. Thank you @Shyju thanks for your help

这篇关于jQuery validate插件无法以MVC形式运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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