I have a form as follows:
I have four inputs in HTMl in which a user enters the following personal information: name, phone, personal id and business id, both the business ID and the staff are unique numbers that are assigned to a single person therefore can not have two people with the same id (personal or business).
<div class="form-group">
<input type="text" id="inputText1" required>
<input type="text" id="inputText2" required>
<input type="text" id="inputText3" required>
<input type="text" id="inputText4" required>
<button type="button" id="submit" value="submitB">Guardar Registro</button>
</div>
$(document).ready(function () {
$("#submit").click(function(e) {
e.preventDefault();
var nombre = $("#inputNombre").val();
var lastname = $("#inputTelefono").val();
var name = $("#inputIdP").val();
var country = $("#inputIdE").val();
Along with the form I have a submit button that enters the information to the database and then in the same form a datatable jQuery is refreshed with the information entered in the corresponding table and all the inputs are cleaned waiting for new information that will follow the same logic (everything works well).
this is the code of my table
<div class="table-responsive">
<table class="table table-striped table-condensed" id="myTable" style="width:100%; margin:0 auto;">
<thead>
<tr>
<th>Nombres</th>
<th>Telefono</th>
<th>idP</th>
<th>idE</th>
</tr>
</thead>
</table>
</div>
and the code with which I charge the datatable
$('#myTable').DataTable({
searching: false,
paging: true,
responsive: true,
"ajax": {
"url": "/home/loaddata",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "nombre", "autoWidth": true, "orderable": false },
{ "data": "telefono", "autoWidth": true, "orderable": false },
{ "data": "idP", "autoWidth": true, "orderable": false },
{ "data": "idE", "autoWidth": true, "orderable": false },
{ "defaultContent": "<button>editar</button>" }
//{ "defaultContent": " <a href='#' id='select'>Modificar</a> "}
],
"oLanguage": {
"sEmptyTable": "No hay registros disponibles",
"sInfo": "Hay _TOTAL_ registros. Mostrando de (_START_ a _END_)",
"sLoadingRecords": "Por favor espera - Cargando...",
"sSearch": "Filtro:",
"sLengthMenu": "Mostrar _MENU_",
"oPaginate": {
"sLast": "Última página",
"sFirst": "Primera",
"sNext": "Siguiente",
"sPrevious": "Anterior"
}
}
});
Now, since the two ids can not be repeated, I would like that if the user has specified in the corresponding inputs one (or both) id that already exists in the datatatable, he / she will be notified of the impossibility of entering the registry but would like to do so using jQuery and not make a trip to the database to verify, but take the value of the inputs and verify me with the information currently presented in the jQuery datatable that are not repeated id