I am trying to validate the dynamically added input type field which are in a row of a table on button click event. The very first input type field has an ID so I am able to put a validation on it. But when I add more rows in the table dynamically , I don't know how to validate those input types of rows.
HTML :
<table class="table table-bordered table-hover" id="tab_logic">
<thead>
<tr>
<th class="text-center">Channel Group Name
</th>
<th class="text-center">Description
</th>
</tr>
</thead>
<tbody>
<tr id='addr0'>
<td id="CGN">
<input type="text" id="channelgrpName" name='channelgrpName' placeholder='Channel Group Name' class="form-control" />
</td>
<td id="DES">
<input type="text" id="description" name='description' placeholder='Description' class="form-control" />
</td>
</tr>
<tr id='addr1'></tr>
</tbody>
</table>
Jquery :
$(document).ready(function () {
var i = 1;
$("#add_row").click(function () {
$('#addr' + i).html("<td><input name='name" + i + "' type='text' placeholder='Channel Group Name' class='form-control' style='width:50%' /> </td><td><input name='mail" + i + "' type='text' placeholder='Description' class='form-control' style='width:50%'></td>");
$('#tab_logic').append('<tr id="addr' + (i + 1) + '"></tr>');
i++;
});
$("#delete_row").click(function () {
if (i > 1) {
$("#addr" + (i - 1)).html('');
i--;
}
});
});
$('#btnSave').click(function () {
// what should i to do here to validate dynamically added input types in row
});
Thanks in advance.
$thisobject