jQuery validate plugin is not working in MVC form

早过忘川 提交于 2019-12-04 06:43:31

问题


I have a MVC form like this

<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>

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

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

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


回答1:


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



来源:https://stackoverflow.com/questions/38708393/jquery-validate-plugin-is-not-working-in-mvc-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!