Uncaught TypeError: Cannot set property 'unobtrusive' of undefined

旧街凉风 提交于 2019-11-28 08:01:50

Another reason this error can occur is if you load the unobtrusive script before jquery.validate.

So,

<script src="/scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>

is OK, but:

<script src="/scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="/scripts/jquery.validate.min.js" type="text/javascript"></script>

will give the "Cannot set property 'unobtrusive' of undefined" error.

Found it. I was missing two lines:

<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/additional-methods.min.js"></script>

I learned this by reading this page which describes how the jquery.validate.unobtrusive script works.

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