jquery - Javascript Validate form group field -
i have form can add dynamically new section fields. how can chceck dynamically input valid (not empty).
my code:
var i= 0; $("#addsection").click(function(e){ e.preventdefault(); i++; var html = '<div>'; html += '<input type="text" name="person['+ +'][name]" value="" />'; html +='<input type="text" name="person['+ '][surname]" value="" /></div>'; var section= $(html); $('#mydiv').append(section); });
this create like:
<div id="mydiv"> <div> <input type="text" name="person[1][name]" value="" /> <input type="text" name="person[1][surname]" value="" /> </div> <div> <input type="text" name="person[2][name]" value="" /> <input type="text" name="person[2][surname]" value="" /> </div> </div>
now want validate names person[1][name], person[2][name], person[3][name], etc. how can validate fields when click submit button?
Comments
Post a Comment