Add validation rules using jquery validate plug-in on dynamically generated elements

后端 未结 2 1546
既然无缘
既然无缘 2020-12-11 12:07

I am trying to add some validation rules on an input created from html literals.

This is my fiddle: http://jsfiddle.net/idoxobi/HW4xY/1/

Html:



        
2条回答
  •  Happy的楠姐
    2020-12-11 12:56

    Its because input field name is same for each, and it has been fixed by @YD1m, my method is as below:

    $(document).ready(function() {
        $('#form').validate();
        var counter = 0;
        $('#Add').click(function() {
            counter++;
            $('#details').append("" + '
    '); }); });

提交回复
热议问题