我目前正在使用bassistance validation plugin来验证我的表单。我使用弹出式模态对话框来容纳需要验证的表单,但由于某种原因它没有调用我的表单……所有我的ID和引用都在工作,但我仍然没有任何成功。
也许有人可以为我解惑。这是我的JavaScript代码。
也许有人可以为我解惑。这是我的JavaScript代码。
$("#addEventDialog").dialog("open");
$("#addEventDialog").dialog({
title: 'Add Event',
modal: true,
buttons: {
"Save": function() {
$("#interestForm").validate({
submitHandler: function(form) {
$("#calendarWidget2").ajaxSubmit({
target: "#calendarResponse",
dataType: 'json',
beforeSubmit: function () {
$('input[type=submit]').attr("disabled", true);
$("#calendarResponse").show('slow');
},
success: function(response, event) {
if(response.status == true) {
$('input[type=submit]').attr("disabled", false);
$("#calendarResponse").delay(5000).fadeOut('slow');
//If the widget says it's okay to refresh, refresh otherwise, consider it done
if(response.refreshEvents == '1') {
$("#calendar").fullCalendar("refetchEvents");
}
// Close the dialog box when it has saved successfully
$("#addEventDialog").dialog("destroy");
// Update the page with the reponse from the server
$("#calendarResponse").append("Successfully Added: "+ response.title +"<br />");
} else {
$("#calendarWidget2").validate();
$("#calendarResponse").append("ERROR: "+ response.status +"<br />");
}
},
error: function() {
alert("Oops... Looks like we're having some difficulties.");
}
});
}
});
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
$("<parent to addEventDialog>").on("dialogopen", function(event, ui) { $("#interestForm").validate();});
- eh1160