jQuery 未捕获的类型错误:对象 [object Object] 没有方法验证
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6394297/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: Object [object Object] has no method validate
提问by wowzuzz
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"> </script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/supersized.3.1.3.core.min.js"></script>
<link rel="stylesheet" type="text/css" href="css/base.css" />
<link rel="stylesheet" href="css/supersized.core.css" type="text/css" media="screen" />
<link href='http://fonts.googleapis.com/css?family=Nunito:light,regular&v1' rel='stylesheet' type='text/css' />
<script type="text/javascript">
$(document).ready(function($){
$.supersized({
//Background image
slides : [ { image : 'images/pendulumWeb.jpg' } ]
});
$("form[name=emailSubmit]").validate({
rules: {
title: {
required: true
},
fName: {
required: true
},
lName: {
required: true
},
profession: {
required: true
},
email: {
required: true,
email: true
}
},
messages: {
title: {
required: "Please enter your title."
},
fName: {
required: "Please enter your first name"
},
lName: {
required: "Please enter your last name."
},
profession: {
required: "Please enter your profession"
},
email: {
required: "Please enter your email"
}
}
});
<div id="contact">
<form id="emailSubmit" name="emailSubmit" method="post">
<legend>Enter InformationEnter InformationEnter InformationEnter InformationEnter InformationEnter InformationEnter InformationEnter Information</legend>
<div id="submit">
<table>
<tr>
<td><span class="formTitles">Title</span></td>
<td><input id="title" name="title" value="" size="5" max="3" type="text" />
</td>
</tr>
<tr>
<td><span class="formTitles">First Name</span></td>
<td><input id="fName" name="fName" value="" size="20" type="text" /></td>
</tr>
<tr>
<td><span class="formTitles">Last Name</span></td>
<td><input id="lName" name="lName" value="" size="20" type="text" /></td>
</tr>
<tr>
<td><span class="formTitles">Profession</span> </td>
<td><input id="profession" name="profession" value="" size="20" type="text" /></td>
</tr>
<tr>
<td><span class="formTitles">Email</span> </td>
<td><input id="email" name="email" value="" size="20" type="text" /></td>
</tr>
<tr>
<td><span class="formTitles">Phone</span></td>
<td><input id="phone" name="phone" value="" size="20" type="text" /></td>
</tr>
<tr>
<td><span class="formTitles">Message</span></td>
<td><input id="message" name="message" value="" size="20" type="textarea" /></td>
</tr>
</table>
<button class="buttonPositive" type="submit"> Submit</button>
</div>
</form>
</div>
<div class="success" style="display: none;">
</div>
I keep getting this error in developer tools
我在开发人员工具中不断收到此错误
Uncaught TypeError: Object [object Object] has no method validate
未捕获的类型错误:对象 [object Object] 没有方法验证
Here is my code..could one of my external js files be causing this? Stuck on this issue.
这是我的代码..我的外部 js 文件之一会导致这种情况吗?卡在这个问题上。
回答by mu is too short
I don't see anything like this:
我没有看到这样的东西:
<script src="jquery.validate.js" type="text/javascript"></script>
in your HTML so you're probably not pulling in the form validatorat all. Without that, jQuery won't have a validate
method so you'll get your "no method validate" error. You will, of course, have to use the right path to jquery.validate.js
for your site.
在你的 HTML 中,所以你可能根本没有拉入表单验证器。没有它,jQuery 将没有validate
方法,因此您将收到“无方法验证”错误。当然,jquery.validate.js
您必须为您的网站使用正确的路径。