此问题是我收到错误,Microsoft JScript运行时错误:对象不支持属性或方法'validate'。无法弄清楚原因。有什么建议吗?
<form id="ContactUs" class="float-left" autocomplete="off">
<div class="box-content">
<div id="Department-List" class="field clearfix">
<select id="DepartmentList" size="1" name="DepartmentList" class="required">
<% foreach(var options in (List<string>)ViewBag.DepartmentList) { %>
<option id="<%:options%>" value="<%:options%>" ><%:options%></option>
<% } %>
</select>
</div>
<div class="field clearfix">
<label class="float-left">NAME:</label>
<input type="text" id="Name" class="required full-width text radi-4" minlength="3"/>
</div>
<div class="field clearfix">
<label class="float-left">PHONE:</label>
<input type="text" id="Phone" class="required PhoneNumbers full-width text radi-4" />
</div>
<div class="field clearfix">
<label class="float-left">EMAIL:</label>
<input type="text" id="SendersEmail" class="required email full-width text radi-4"/>
</div>
<div class="field clearfix">
<label class="float-left">ACCOUNT #:</label>
<input type="text" id="AccountNumber" class="full-width text radi-4" />
</div>
<div class="field clearfix">
<label class="float-left">QUESTIONS:</label>
<textarea id="QuestionBox" rows="4" cols="25" class="required full-width text radi-4"></textarea>
</div>
<div class="field clearfix">
<input id="submit-inventory-request-button" type="submit" name="Submit" value="Send" class="submit next-step toggle-btn radi-3 arrow-icon" />
</div>
当我尝试提交表单时,我收到来自$('#ContactUs')。validate()函数的错误。
<script type="text/javascript">
$(document).ready(function () {
$('#ContactUs').validate({
errorElement: 'span',
success: 'valid',
error: 'error',
submitHandler: function() {
var contact = {
DepartmentList: $('#DepartmentList').val()
, Name: $('#Name').val()
, Phone: $('#Phone').val()
, SendersEmail: $('#SendersEmail').val()
, RequestersEmail: $('#RequestersEmail').val()
, AccountNumber: $('#AccountNumber').val()
, QuestionBox: $('#QuestionBox').val()
, TermsCheckBox: $('#TermsCheckBox').val()
};
var req;
req = DT.ajaxData('/Ajax/ContactUs/', 'POST', JSON.stringify(contact));
// if the ajax request is successful, then display the success message and redirect the page
req.done(function(data) {
console.log(data);
$("#partial").dialog('close');
$("#SuccessMessage").dialog({ buttons: { "Ok": function() { $(this).dialog("close"); } } });
});
return false;
}
});
})
答案 0 :(得分:6)
答案 1 :(得分:1)
如果使用Visual Studio,最简单的方法是使用NuGet扩展来下载jQuery。如果您没有它,可以在www.codeplex.com找到并安装它。然后转到工具 - &gt;库包管理器 - &gt;在Visual Studio中管理NuGet包并搜索jQuery。安装完成后,项目中的Script文件夹将包含所需的文件。
修改view.cshtml文件中的路径以指向当前版本的jQuery,例如1.7.1