Working on clone in jQuery. With my current code original div getting cloned validation working fine for the original one and cloned one. These things are working with my code.
- Initially if the user click next button it will show the message as You have missed 7 fields. Please fill before submitted. Once the user starts fill the fields it will automatically starts get reduced.
- If the user clicked the add more button it will get cloned the div.
- Once the user starts fills any of the field in the cloned one and he missed the rest of the mandatory fields if user click the next button it will show these many number of fields are missed.
Below things are not working:
- With my current code if I have select drop down / radio button in the cloned div validation was not working
The validation count was wrong after the cloned
function bind_change_events(){ $('.cloned_field').on('input',function(e){ if($(this).val().trim().length > 0) { //$(this).removeClass("cloned_field"); $(this).addClass("required_field"); var parent_div = $(this).closest("div.cloned-row1,div.cloned-row2,div.cloned-row3,div.cloned-row4,div.cloned-row5").find("input","select"); parent_div.each(function () { $(this).addClass("required_field"); }); } check_for_validation_removal($(this)); bind_validation(); }); }
Here is the updated fiddle.
See Question&Answers more detail:os