I am using bassistance.de/jquery-plugins
and this is default jQuery form validation service.
I am aware that question related to jQuery validation asked
Every input needs an unique name. The plugins fails to consider things like name="location[]", you have to add an index (correct would have been name="location[0]"). For cloned elements I get first the html "clone().html()" then I replace the [0] with a counter number i keep track Ex: .replace(/[0]/g, "["+cont+"]")
then I can safely append the generated html to the DOM and the plugin works as usual.
REMEMBER: JQUERY VALIDATE NEEDS AN UNIQUE NAME IN THE INPUT!! I pay myself with a lot of hours lost for this.
Solve it !
What I used to do: after I clone the object, I called a function that creates the validation:
function add_another_form(){
var new_form = jQuery(".class").clone(true);
new_form.appendTo(".parent");
add_validation_for_forms();//attach again the validation !
}
function add_validation_for_forms(){
jQuery(".class").validate({....})
But that was not working, so I just used a .each function in there, and it works now...
function add_validation_for_forms(){
jQuery(".class").each(function(){
jQuery(this).validate({....})