How to validate clone elements in jQuery validation?

前端 未结 2 1279
失恋的感觉
失恋的感觉 2020-12-19 14:36

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

2条回答
  •  抹茶落季
    2020-12-19 15:07

    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.

提交回复
热议问题