我得到了未捕获的TypeError:尽管包括jquery.validate.js,但对象[object Object]没有方法'validate'。 我的页面是平均堆栈应用程序的一部分。
这是包含的全部脚本集:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
<script src="lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.13.0/jquery.validate.js"></script>
<script src="js/formValidation.js"></script>
<script>
function validate()
{
console.log("Entering");
jQuery(".form-inline").validate({
rules: {
"your-name": {
required: true
},
"your-email": {
required: true,
email: true
},
"your-phone": {
required: true
},
"your-checkin": {
required: true
},
"your-checkout": {
required: true
},
},
messages: {
"your-name": {
required: "Please provide the required field",
},
"your-email": {
required: "Please provide the required field",
email : "Please provide a valid email-ID"
},
"your-phone": {
required: "Please provide the required field",
},
"your-checkin": {
required: "Please provide the required field",
}
,
"your-checkout": {
required: "Please provide the required field",
}
},
errorPlacement: function(error, element) {
console.log(element);
if (element.attr("name")=="your-name") {
error.appendTo("#nameError");
}
else if (element.attr("name")=="your-email") {
error.appendTo("#emailError");
}
else if (element.attr("name")=="your-phone") {
error.appendTo("#phoneError");
}
if (element.attr("name")=="your-checkin") {
error.appendTo("#checkinError");
}
if (element.attr("name")=="your-checkout") {
error.appendTo("#checkoutError");
}
},
submitHandler: function(form) {
getNotify();
}
});
}
function getNotify(){
console.log(jQuery('form #Name').val());
var deviceInfo = platform;
var appointment = {
inquirer: jQuery('form #Name').val(),
email: jQuery('form #Email').val(),
phone: jQuery('form #phone').val(),
checkinDate: jQuery('form #date-picker-2').val(),
checkinDate: jQuery('form #date-picker-3').val()
};
console.log(appointment);
jQuery.ajax({
type: "POST",
url: "http://aashish.digiapt.com/bookings",
crossDomain: true,
data: appointment,
dataType: "json",
success: function( response )
{
console.log("response with:",response);
},
error: function( error )
{
console.log( "ERROR:", error );
},
complete: function()
{
jQuery('#Message-success-label').show();
jQuery('#Message-success-label').fadeOut(8000);
jQuery('form #Name').val('');
jQuery('form #Email').val('');
jQuery('form #phone').val('');
jQuery('form #date-picker-2').val('');
jQuery('form #date-picker-3').val('');
console.log("done");
}
});
}</script>
我可以包含标签。但我仍然得到错误: 尽管jquery.validate.js