I have three text boxes called DATO1 DATO2 DATO3
, I would like to check that they were not empty, the problem that arises is that I want to check whether they are filled in order or not. (DATA1 -> DATA2 -> DATA3)
Since, since I have the script, it checks if I fill DATA1 then DATA2, and it shows its respective messages, but if the person fills DATA2, it does not check DATA1.
How can I order the IF to check the 3 text boxes:
Note: respuesta.obtuvo
is a value obtained by JSON, if it gives 0, that is to say that some field of DATA was not filled, because when a DATA is filled, it brings with it other values.
Here my code:
HTML:
DATO1
<input type="text" name="dato1" id="dato1">
DATO2
<input type="text" name="dato2" id="dato2">
DATO3
<input type="text" name="dato3" id="dato3">
jQuery
if(respuesta.obtuvo==0)
{
alert("Debe ingresar los datos de lo incurridos en la falta");
$('select[name=medida]').val(0);
if ($('#dato1').val()=="") {
$("#dato1").focus();
}
if ($('#dato2').val()=="") {
$("#dato2").focus();
}
if ($('#dato3').val()=="") {
$("#dato3").focus();
}
}