I want validate my table if empty. my table using datatables to add data.
<form method="post" id="form">
<input type="text" id="txt" required>
<table id="table">
<thead>
<tr>
<th>No.</th>
<th>Name</th>
<th>Address</th>
</tr>
</thead>
</table>
<button id="button" type="submit">Save</button>
</form>
my jquery:
$(document).ready(function () {
var grid = $('#table').DataTable();
grid.row.add([
'1',
'Jake',
'England'
]).draw(false);
$("#form").validate({
submitHandler: function (form) {
form.submit();
}
});
});
If input. I'm just add required attribute. but how to check datatables if the table empty. If I'm not add some item. It's will be return message error in above table or top table
NB: this how to check datatables empty table.data().any()