below is TextBox, on which i am adding barcode into html table.
<div class="row">
<div style="display: inline-block;">
<div>
@Html.LabelFor(model => model.Prdno, "Barcode", htmlAttributes: new { @class = "control-label col-md-4" })
@Html.EditorFor(model => model.Prdno, new { htmlAttributes = new { @class = "form-control col-md-10", @id = "Search_Prdno" } })
@Html.ValidationMessageFor(model => model.Prdno, "", new { @class = "text-danger" })
</div>
</div>
for adding row in html table using below Array
function addrow() {
$('#btnInsert').add(function () {
var tbody = $('#DataInsert tbody');
var tr = $('<tr></tr>');
tr.append('<td>' + $('#Barcode_Bale').val() + '</td>');
tr.append('<td>' + $('#Bale_Qty').val() + '</td>');
tr.append('<td>' + $('#select2-3').text() + '</td>');
tr.append('<td>' + $('#select2-3').val() + '</td>');
tr.append('<td><input class="del" type="button" value="Delete" /></td>')
// Checking Duplicate Barcode
var items = ['<td>' + $('#Barcode_Bale').val() + '</td>'];
var item = $('#Search_Prdno').val();
if ($.inArray(item, items) != -1) // or if (items.indexOf(item) != -1)
{
$('#spnMessage').html(item + ' found');
}
else {
$('#spnMessage').html(item + ' not found');
}
tbody.append(tr);
$('#Search_Prdno').val(null);
$('#Search_Prdno').focus();
});
}
but i want, when adding row into html table, it check barcode exits in table then ,it should not add row ,if barcode does not exist in html table, then add row