jQuery validate plugin is not working in MVC form

2019-03-04 03:36发布

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条回答
啃猪蹄的小仙女
2楼-- · 2019-03-04 04:14

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

查看更多
登录 后发表回答