When using the jQuery validation plugin, how do I validate a form that is generated using ajax?
I mean to ask, the form does not initially appear on the page when the page loads, but is added to the page using ajax.
I'm following the examples on bassistance.de/jquery-plugins/jquery-plugin-validation/, but it seems that the validation plugin will not validate the form. Otherwise, it works fine. Is there a way to do this. Just like jquery uses live(), is there something I can use to make the plugin work in this scenario?
I'm doing things this way:
$("#thisForm").validate({
rules: {
},
messages: {
},
submitHandler: function() {
$.ajax({
type: "POST",
url: "/",
data: $('#thisForm').serialize(),
dataType: "json",
cache: false,
beforeSend: function(html) {
},
success: function(signInData) {
},
});
}
});
validatemethod to add validation to your form, as soon you add it to the dom after the ajax call