[jQuery] Validate
[jQuery] Validate
I am new to jquery(my first application!) and I am using the
fantastic validate plugin. I am calling a dialog from a tab and
although the validation works perfectly if you keep accessing the
dialog window after about 4 times it causes internet explorer to
display the 'Stop running this script message as causing computer to
run slowly' message.
I have posted the script below and would be grateful for any help!!
$(".manageOpportunity").click(function(e) {
// alert("Manage OP");
var oOpportunity = document.createElement("div");
oOpportunity.setAttribute("id", "OpportunityDiv");
oOpportunity.setAttribute("title", "Manage Opportunity");
$("body").append(oOpportunity);
$('#opportunityDetailForm').livequery(function() {
$('input.date-picker').datePicker({startDate:'01/01/2009'});
$(this).ajaxForm({
beforeSubmit: function(formData, jqForm, options) {
return $('#opportunityDetailForm').validate({
debug: true,
rules: {
description: "required",
openDate: "required",
statusCodes: "required",
stageCode: "required",
decisionMakerId: "required",
repId: "required",
competitorCodes: "required"
},
messages: {
description: "Please enter an Opportunity Name",
openDate: "Please enter an Open Date",
statusCodes: "Please select a Status",
stageCode: "Please select a Stage Code",
decisionMakerId: "Please select a Descision Maker",
repId: "Please select a Sales Rep",
competitorCodes: "Please select a Competitor"
},
errorClass: "errors",
validClass: "noerrors",
errorContainer: "#formErrors",
errorLabelContainer: "#formErrors ul",
errorElement: "li",
highlight: function(element, errorClass) {
$(element.form).find("label[for=" + element.id + "]").addClass
(errorClass);
},
unhighlight: function(element, errorClass) { $
(element.form).find("label[for=" + element.id + "]").removeClass
(errorClass);
}
}).form();
},
success: function() {
$("#OpportunityDiv").dialog("destroy").remove();
$("#tabs").tabs('load', 4);
},
url: "companyOpportunityDetail.do?mode=manageSubmit",
type: "post"
});
$('#opportunityDetailForm').expire();
});