I've made a form where some of the elements are added using AJAX (post). You press a button to add the elements which are generated by a php page.
The jQuery validation (https://jqueryvalidation.org/) doesn't work on the elements that have been added using AJAX. I've tested the page replacing the AJAX elements with regular elements in the page and it works fine, so I think it's the AJAX.
Here's the jQuery:
$("#editEventFormNew").validate (
{
rules: {
artwork: { filesize: 2097152 },
name: {
required: true,
minlength: 2,
maxlength: 50
},
desc: {
required: true,
minlength: 2,
maxlength: 3000
},
venue2: {
required: true
},
staDate: {
required: true,
//greaterThan: "dateHigherThanToday"
},
endDate: {
required: true,
greaterThan: "#staDate3"
},
cutDate: {
required: true,
lessThan: "#endDate3"
},
shoDate: {
required: true,
lessThan: "#staDate3"
},
totalSubCat: {
minStrict: 0,
maxStrict: 4
},
},
messages: {
name: "Enter the event name, longer than 2 and less than 50 characters",
desc: "Enter a description, longer than 2 and less than 3000 characters",
venue2: "Choose a venue",
staDate: "Start must be after today",
endDate: "End must be after the Start",
cutDate: "Cut Off must be before the End",
shoDate: "Show From must be before the Start",
totalSubCat: "Choose between 1 and 3 categories"
}
}
);
staDate, endDate, cutDate, shoDate are created using AJAX when a button on the form is pressed. The form elements are ignored by the jQuery.