javascript - jQuery clone validation not working for HTML drop down -


working on clone in jquery. current code original div getting cloned validation working fine original 1 , cloned one. these things working code.

  1. initially if user click next button show message you have missed 7 fields. please fill before submitted. once user starts fill fields automatically starts reduced.
  2. if user clicked add more button cloned div.
  3. once user starts fills of field in cloned 1 , missed rest of mandatory fields if user click next button show these many number of fields missed.

below things not working:

  1. with current code if have select drop down / radio button in cloned div validation not working
  2. the validation count wrong after 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 updated fiddle.

when cloning elements, not clone class .required_field. in code class, adds required: true part.

i figured out problem in cloning part.

if($(this).hasclass("required_field")) {    $(this).removeclass("required_field");    $(this).addclass("cloned_field");    //$(this).addclass("errred"); }else{    $(this).removeclass("errred");    $(this).removeclass("text-error-red"); } 

you had if has class required_field, remove it. deleted line $(this).removeclass("required_field"); , when adding more education forms, increased unfilled count.

i tested same idea second cloning part. , did job. solution count.

now talking cloned div or radio button not working in code, in liveweave code, drop downs works me, tho can't find radio buttons.

please try answer specified, , if problems keep exist, please update question or leave comment here.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -